package java2017;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class writer {
public static void main(String[] args) {
// TODO Auto-generated method stub
int ch;
try{
File file=new File("./bin//Hello.txt");
FileWriter fw=new FileWriter(file);
fw.write("Hello world! How are you!");
fw.close();
FileReader fr=new FileReader(file);
while((ch=fr.read())!=-1)
System.out.print((char)ch);
fr.close();
}catch(FileNotFoundException e){
System.out.println("文件不存在");
}catch(IOException e){
System.out.println("发生IOE操作异常");
}
}
添加回答
举报
0/150
提交
取消