我尝试了以下示例,它工作正常:
package com.test;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
public class Test {
public static void main(String[] args) throws IOException {
//OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(fileName), StandardCharsets.ISO_8859_1);
OutputStream outputStream = new FileOutputStream("c:\\output.txt");
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream,
StandardCharsets.ISO_8859_1);
outputStreamWriter.write("When it is not possible to use the umlauts (for example, when using a restricted character set) the characters Ä, Ö, Ü, ä, ö, ü should be transcribed as Ae, Oe, Ue, ae, oe, ue respectively, following the earlier postvocalic-e convention; simply using the base vowel (e.g. u instead of ü) would be wrong and misleading. However, such transcription should be avoided if possible, especially with names. Names often exist in different variants, such as \"Müller\" and \"Mueller\", and with such transcriptions in use one could not work out the correct spelling of the name.");
outputStreamWriter.close();
}
}
输出: 当无法使用元音变音时(例如,使用受限字符集时)字符 Ä、Ö、Ü、ä、ö、ü 应转录为 Ae , Oe, Ue, ae, oe, ue 分别遵循较早的 postvocalic-e 约定;简单地使用基本元音(例如 u 而不是 ü)是错误的和误导性的。但是,如果可能的话,应该避免这种转录,尤其是名字。名称通常以不同的变体形式存在,例如“Müller”和“Mueller”,并且在使用此类转录时,人们无法确定名称的正确拼写。
让我知道单词是否正确编码,因为我无法阅读德语。