Snippets tagged “byte-array”
8 snippets use this tag.
- Convert a string representation of a hex dump to a byte array using Java?Java
To convert a string representation of a hex dump to a byte array in Java, you can use the DatatypeConverter class's parseHexBinary method.
- Convert InputStream to byte array in JavaJava
To convert an InputStream to a byte array in Java, you can use the readAllBytes() method of the java.nio.file.Files class from the java.nio.file package.
- Decode Base64 data in JavaJava
To decode base64 data in Java, you can use the Base64.Decoder class introduced in Java 8. Here's an example of how to use it:
- How do I initialize a byte array in Java?Java
To initialize a byte array in Java, you can use the array initializer syntax, like this:
- How to convert a byte array to a hex string in Java?Java
To convert a byte array to a hexadecimal string in Java, you can use the following method:
- How to convert Java String into byte[]?Java
To convert a Java string into a byte array, you can use the getBytes() method of the java.lang.String class. This method returns an array of bytes representing the string in a specific encoding.
- Java Byte Array to String to Byte ArrayJava
To convert a byte array to a string and back to a byte array in Java, you can use the getBytes method of the String class and the getBytes method of the Charset class.
- UTF-8 byte[] to StringJava
To convert a byte array to a string in UTF-8 encoding, you can use the following method in Java: