在 Java 中將位元組轉換為字串


使用 String(byte[]) 建構函式將 byte[] 轉換為 String。

示例

public class Tester {
   public static void main(String[] args) {
      String test = "I love learning Java";
      byte[] bytes = test.getBytes();
      String converted = new String(bytes);
      System.out.println(converted);
   }
}

輸出

I love learning Java

更新於: 2020 年 2 月 24 日

538 次瀏覽

開啟你的 職業生涯

完成課程認證

開始學習
廣告
© . All rights reserved.