跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • Java 字节数组通过 UTF-8 编码成字符串后,无法恢复到原始字节数组
未分類
15 5 月 2020

Java 字节数组通过 UTF-8 编码成字符串后,无法恢复到原始字节数组

Java 字节数组通过 UTF-8 编码成字符串后,无法恢复到原始字节数组

資深大佬 : yanshenxian 5

代码如下

byte[] bytes = new byte[] {39, 10, -111, -111, 54, 68, -2, 89, 68, 20, -92, 73, -83, -11, -5, -54, -122, -127, 97, 64}; String stringValue = new String(bytes, StandardCharsets.UTF_8); byte[] newBytes1 = stringValue.getBytes(StandardCharsets.UTF_8); byte[] newBytes2 = stringValue.getBytes(StandardCharsets.ISO_8859_1); // 输出 false System.out.println(Arrays.equals(bytes, newBytes1)); // 输出 false System.out.println(Arrays.equals(bytes, newBytes2)); 

我要怎么将一个 UTF-8 编码的字符串恢复成原始字节数组呢

大佬有話說 (1)

  • 主 資深大佬 : yanshenxian

    自答: 在 Stack Overflow 上找到答案了
    is-there-a-way-to-recover-a-byte-array-that-represents-a-string-that-is-saved-a

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具