Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
文字列に変換したい ASCII 文字で構成されるバイト配列があります。例えば:
byte[] myByteArray = new byte[8]; for (int i=0; i<8; i++) { byte[i] = (byte) ('0' + i); }
myByteArray には、ループの後に文字列 "12345678" が含まれている必要があります。この文字列を文字列変数に入れるにはどうすればよいですか?
ありがとう!
使用する
new String(myByteArray, "UTF-8");
String クラスは、このためのコンストラクターを提供します。
補足: ここでの 2 番目の引数は、慎重に処理する必要があるCharSet (バイト エンコーディング) です。詳細はこちら。