How-to articles, tricks, and solutions about BYTE

Convert a string representation of a hex dump to a byte array using 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.

How do I initialize a byte array in Java?

To initialize a byte array in Java, you can use the array initializer syntax, like this:

Java Byte Array to String to Byte Array

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.

TypeError: a bytes-like object is required, not 'str' when writing to a file in Python 3

This error occurs when you are trying to write a string to a file using the write() method in Python 3, but the file is opened in binary mode (using the 'b' flag when opening the file).