如何在UTF-8中打开文件并在UTF-16中写另一个文件 [英] How to Open File in UTF-8 and Write in Another File in UTF-16
本文介绍了如何在UTF-8中打开文件并在UTF-16中写另一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在UTF-8中打开文件并在UTF-16中写入另一个文件?
我需要一个例子,因为我遇到一些诸如é"和"a"之类的字符的问题.
I need an example because I'm having issues with some characters like 'é' and 'a'.
在编写médic"时,我在文件中找到了"m @#dic".
When writing "médic", I find in the file written "m@#dic".
推荐答案
您可以按以下方式创建阅读器:
You can create a reader as follows:
InputStream is = new FileInputStream(inputFile);
InputStreamReader in = new InputStreamReader(is, "UTF-8");
和作家如下:
OutputStream os = new FileOutputStream(outputFile);
OutputStreamWriter out = new OutputStreamWriter(os, "UTF-16");
这篇关于如何在UTF-8中打开文件并在UTF-16中写另一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文