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


使用 String(byte[]) 建構函式將位元組陣列轉換為字串。

示例

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

更新於: 24-Feb-2020

537 次瀏覽

開啟您的 職業生涯

完成課程獲得認證

開始
廣告
© . All rights reserved.