import java.io.*;
public class Test {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws FileNotFoundException, IOException {
FileWriter fw = new FileWriter("test.txt");
fw.write("dddd");//直接这样就行..他会自动转换为其Unicode编码..或者fw.write((int)c);强制转换一下也行
fw.append("wwwwww");
fw.flush();
fw.close();
FileReader fr = new FileReader("test.txt");
int ch = 0;
while((ch = fr.read())!=-1 )
{
System.out.print((char)ch);
}
}
}
【java】各种对文件,读写的方法及小例子
最新推荐文章于 2024-09-22 22:15:03 发布