我正在开发一个应用程序,它打开一个文件并将其内容写入另一个具有不同名称的现有文件中。
问题是ASCII(我认为)中不存在的一些字符,例如(char)144或(char)154,被替换为(char)63或***问号->?。
我尝试更改 VM 字符集,但问题没有解决。这里是我们感兴趣的部分代码:
File out = new File("new_clientK.swf");
BufferedReader reader = new BufferedReader(new FileReader(new File("input.swf")));
PrintWriter writer = new PrintWriter(new FileWriter(out));
String line = null;
//The first line is edited
line = reader.readLine();
writer.append(line.replace(oldstring, newstring));
writer.append((char) 10);
//The first line is added, now, I get all the remaining code and add it
//char by char
int charnum = 0;
while ((charnum = reader.read()) != -1) {
writer.append((char) (charnum));
}
reader.close();
writer.close();