String to binary?

If I want to convert a string to binary code, what is the best approach? Do I convert each char ascii and then convert ascii to binary?

If you convert it to ascii yourself you may lose some information. It’s petter to use String.toBytes(String charsetName) or DataOutput.writeUTF(String).