public void writeData(File file){
StringBuilder builder = new StringBuilder();
FileOutputStream fos = null;
OutputStreamWriter writer= null;
try {
fos = new FileOutputStream(file) ;
writer = new OutputStreamWriter(fos,"utf-8"); //制定编码格式
writer.write(builder.toString());
} catch (FileNotFoundException e) {
} catch (IOException e) {
} finally{
if(writer != null){
try {
writer.close();
} catch (IOException e) {
}
}
if(fos != null){
try {
fos.close();
} catch (IOException e) {
}
}
}
}
|