/** * Returns an Integer from a String * * @param val * String to parse * @param offset * Offset to start parsing */ public static int getIntFromString(String val, int offset) { char[] chrCode = new char[CHARSIZE]; byte[] comCode; chrCode = val.ToCharArray(offset, offset + CHARSIZE); comCode = ByteProcess.charArrayToByteArray(chrCode); return(ByteProcess.byteArrayToInt(comCode, 0)); }
/** * Creates a byte array from a Char array * * @param charArray * Array of characters to convert */ public static byte[] charArrayToByteArray(char[] charArray) { byte[] byteArray = new byte[charArray.Length * 2]; byte[] tmpArray; for (int s = 0; s < charArray.Length; s++) { tmpArray = ByteProcess.charToByteArray(charArray[s]); byteArray = ByteProcess.appendToByteArray(byteArray, tmpArray, s * 2); } return(byteArray); }
/** * Creates a Char array from a byte array * * @param byteArray * Array of bytes to convert */ public static char[] byteArrayToCharArray(byte[] byteArray) { int size = byteArray.Length / 2; char[] charArray = new char[size]; byte[] tmpArray; for (int s = 0; s < size; s++) { tmpArray = ByteProcess.getSubByteArray(byteArray, s * 2, (s + 1) * 2); charArray[s] = byteArrayToChar(tmpArray); } return(charArray); }