标签:java bytes puts 文本 public buffer his col 写文本
package rw; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; public class test { public static void main(String[] agrc) throws IOException { //写入文件 FileOutputStream out = new FileOutputStream("test.txt"); for(int i=0;i<100;i++) { String s = "this line is " + i+"\n"; out.write(s.getBytes()); } out.close(); //读取文件 FileInputStream in = new FileInputStream("test.txt"); // 读取文件路径 BufferedReader br = new BufferedReader(new InputStreamReader(in)); for(int i=0;i<100;i++) { String line = br.readLine(); System.out.println(line); } br.close(); in.close(); } }
标签:java bytes puts 文本 public buffer his col 写文本
原文地址:http://www.cnblogs.com/tiandsp/p/7467878.html