gpt4 book ai didi

java - 在 OutputStreamWriter 中选择文件编码

转载 作者:行者123 更新时间:2023-11-29 03:38:48 26 4
gpt4 key购买 nike

我在 Linux 服务器上使用 JDK 1.7。我已经安装了 apache 6.0.35 并使用代码

Writer w = new OutputStreamWriter(os,"Unicode");

以unicode格式写入文件。

但是文件是以 unicode big endian 格式生成的。如何选择不同的输出格式?

最佳答案

“Unicode”不是单一格式,而是指定编码,如 UTF-16(大端和小端)和 UTF-8。

您可能想要一些特定的东西,比如 UTF-16LE 而不是 Unicode。查看 http://docs.oracle.com/javase/7/docs/api/java/nio/charset/StandardCharsets.html 中的列表

关于java - 在 OutputStreamWriter 中选择文件编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14137037/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com