写文件操作测试

public void writeResults() {
String fullFileName = catalog + "/testResult/result.txt";

FileWriter fw = null;
BufferedWriter bw = null;
try {
fw = new FileWriter(fullFileName, false);
bw = new BufferedWriter(fw);

bw.write("========" + date + "========");
bw.newLine();
bw.write("as_time :" + asTime);
bw.newLine();
bw.write("as_data_size :" + asDataSize);
bw.newLine();
bw.write("ke_time :" + keTime);
bw.newLine();
bw.write("ke_data_size :" + keDataSize);
bw.newLine();
bw.write("=============== end ==============");
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bw != null) {
try {
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fw != null) {
try {
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

posted @ 2020-04-09 15:32  工设091  阅读(106)  评论(0)    收藏  举报