1 2 17 18 19 20 package org.apache.poi.hdf.extractor; 21 22 27 28 public class Utils 29 { 30 31 public static short convertBytesToShort(byte firstByte, byte secondByte) 32 { 33 return (short)convertBytesToInt((byte)0, (byte)0, firstByte, secondByte); 34 } 35 public static int convertBytesToInt(byte firstByte, byte secondByte, 36 byte thirdByte, byte fourthByte) 37 { 38 int firstInt = 0xff & firstByte; 39 int secondInt = 0xff & secondByte; 40 int thirdInt = 0xff & thirdByte; 41 int fourthInt = 0xff & fourthByte; 42 43 return (firstInt << 24) | (secondInt << 16) | (thirdInt << 8) | fourthInt; 44 } 45 public static short convertBytesToShort(byte[] array, int offset) 46 { 47 return convertBytesToShort(array[offset + 1], array[offset]); 48 } 49 public static int convertBytesToInt(byte[] array, int offset) 50 { 51 return convertBytesToInt(array[offset + 3], array[offset + 2], array[offset + 1], array[offset]); 52 } 53 public static int convertUnsignedByteToInt(byte b) 54 { 55 return (0xff & b); 56 } 57 public static char getUnicodeCharacter(byte[] array, int offset) 58 { 59 return (char)convertBytesToShort(array, offset); 60 } 61 62 } 63 | Popular Tags |