我的Netbeans
文件查看器存在问题。我有一个阿拉伯语字符串,每个字母顶部都包含重音符号。当我从字符串中删除重音时,字母会正确显示。但是,当我用重音符号写字符串时,它会以某种方式混乱(不正确)。
这是正在发生的事情的一个例子:
بسم الله الرحمن الرحيم
it shows broken, but if i copy it here it prints correctly
بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيمِ
我写的代码是读取包含阿拉伯字符串及其重音的文本文件,然后在新文件中正确写入,最后删除旧文件。这是代码:
public void arabicReformer(File disordered) {
File output = new File("data/temp2.txt");
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(disordered), "UTF8"));
BufferedWriter bw = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(output), "UTF8"));
String line;
while ((line = br.readLine()) != null) {
bw.write(line.trim() + "\n");
}
br.close();
bw.close();
} catch (UnsupportedEncodingException e) {
System.out.println(e.getMessage());
} catch (IOException e) {
System.out.println(e.getMessage());
} catch (Exception e) {
System.out.println(e.getMessage());
}
output.renameTo(disordered);
}
PS:当我复制过去带有重音的错误的阿拉伯字符串时,它会正确打印!