どのように文字列をJavaのバイトに変換するのですか?
ここでは、Stringの
getBytes()
関数を使用してStringをByte ** 変数に変換する方法を示します。
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); } }
出力
Text : This is an example Text[Byte Format]:[B@187aeca
リンク://タグ/バイト/[バイト]リンク://タグ/java/[java]リンク://タグ/文字列/[文字列]