List of utility methods to do Byte Array Convert To
byte[] | BytesTobytes(Byte[] bytes) Bytes Tobytes byte[] result = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) { result[i] = bytes[i]; return result; |
char[] | bytesToChars(byte[] bytes) Converts bytes to chars without using any external functions that might allocate additional buffers for the potentially sensitive data. char[] chars = new char[bytes.length / 2]; for (int i = 0; i < chars.length; i++) { char v = (char) (((0xFF & (bytes[i * 2])) << 8) | (0xFF & bytes[i * 2 + 1])); chars[i] = v; return chars; |
char[] | bytesToChars(byte[] data, String enc) Convert byte array to char array String str; try { str = new String(data, enc); } catch (Exception e) { str = new String(data); char[] chars = new char[str.length()]; str.getChars(0, chars.length, chars, 0); ... |
String | bytesToCharset(final byte[] bytes, final String charset) bytes To Charset try { return new String(bytes, charset); } catch (Exception e) { e.printStackTrace(); return null; |
byte[] | bytesToCompressedBases(final byte[] readBases) Convert from a byte array containing =AaCcGgTtNn represented as ASCII, to a byte array half as long, with =, A, C, G, T converted to 0, 1, 2, 4, 8, 15. final byte[] compressedBases = new byte[(readBases.length + 1) / 2]; int i; for (i = 1; i < readBases.length; i += 2) { compressedBases[i / 2] = (byte) (charToCompressedBaseHigh(readBases[i - 1]) | charToCompressedBaseLow(readBases[i])); if (i == readBases.length) { compressedBases[i / 2] = charToCompressedBaseHigh((char) readBases[i - 1]); ... |
byte[] | bytesToCompressedBases(final byte[] readBases) Convert from a byte array containing =AaCcGgTtNn represented as ASCII, to a byte array half as long, with =, A, C, G, T converted to 0, 1, 2, 4, 8, 15. final byte[] compressedBases = new byte[(readBases.length + 1) / 2]; int i; for (i = 1; i < readBases.length; i += 2) { compressedBases[i / 2] = (byte) (charToCompressedBaseHigh(readBases[i - 1]) | charToCompressedBaseLow(readBases[i])); if (i == readBases.length) { compressedBases[i / 2] = charToCompressedBaseHigh((char) readBases[i - 1]); ... |
byte[][] | bytesToData(byte[][] fileData) bytes To Data byte[][] data = new byte[fileData.length / 2][]; for (int i = 1; i < fileData.length; i += 2) { data[i / 2] = fileData[i]; return data; |
String | bytesToDec(byte[] bytes) bytes To Dec StringBuffer buffer = new StringBuffer(); for (byte b : bytes) { buffer.append(b & 0xFF); return buffer.toString(); |
String | bytesToEntryCreditAddress(byte[] key) bytes To Entry Credit Address String address = ""; return address; |
int | BytesToInt(byte abyte0[], int offset) Bytes To Int return (int) to_number(abyte0, offset, 2); |