Wie konvertiere ich String in Byte in Java?
Hier zeige ich, wie die Variableconvert a String to a Bytemit der FunktiongetBytes()von String funktioniert.
public class TestByte { public static void main(String[] argv) { String example = "This is an example"; byte[] bytes = example.getBytes(); System.out.println("Text : " + example); System.out.println("Text [Byte Format] : " + bytes); } }
Ausgabe
Text : This is an example Text [Byte Format] : [B@187aeca