import java.io.FileWriter;
import java.io.FileReader;
import java.io.IOException;
class Demo06
{
public static void main(String[] args)
{
FileWriter fw = null;
char[] ch1 ={'a','v','d'} ;
try{
fw= new FileWriter("ccc.txt");
fw.write("我是好人\r\n");
//fw.write("\r\n");
fw.write("但是我其实是坏人\r\n");
fw.write(ch1);
fw.flush();
FileReader fr = new FileReader("ccc.txt");
int ch = 0;
while ((ch=fr.read())!=-1)
{
System.out.println(ch);
}
}catch(IOException e)
{
e.printStackTrace();
}finally
{
if(fw!=null)
{
try{
fw.close();
}catch(IOException e){
e.printStackTrace();
}
}
}
}
}
|
|