62,614
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args){
BufferedWriter write = null;
BufferedReader reader=null;
String str = null;
try {
write = new BufferedWriter(new FileWriter("D:\\abc.txt"));
write.write("HELLO WORD");
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
write.flush();
write.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
reader = new BufferedReader(new FileReader("D:\\abc.txt"));
str = reader.readLine();
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println(str);
}