java文件读写

更全的参照如下连接 http://hi.baidu.com/general_li/blog/item/6db0107bc8c3a3fc0ad1879e.html

读:
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("ming.txt")));
String data = null;
while((data = br.readLine())!=null)
{
System.out.println(data);
}

写:
FileWriter fw = new FileWriter("hello.txt");
String s = "hello world";
fw.write(s,0,s.length());
fw.flush();

你可能感兴趣的:(java,html,Blog)