StringpathName="d://xxx.doc";Filefile=newFile(pathName);try{if(file.exists()){file.delete();//如果存在就删除该文本}file.createNewFile();//bw=newBufferedWriter(newOutputSt...
String pathName = "d://xxx.doc";
File file = new File(pathName);
try {
if (file.exists()) {
file.delete();// 如果存在就删除该文本
}
file.createNewFile();
// bw = new BufferedWriter(new OutputStreamWriter(
// new FileOutputStream(file),"UTF-8"));
bw = new BufferedWriter(new FileWriter(file));
String str = compareCode.getText();
bw.write(str);
bw.newLine();
bw.close();
bw = null;
file = null;
} catch (IOException e) {
if (bw != null) {
try {
bw.close();
} catch (IOException e1) {
}
bw = null;
}
}
打开时总是询问编码问题
展开