java 输入输出-课堂作业7-6

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.channels.FileLock;


public class Bwriter {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		InputStreamReader  i= new InputStreamReader(System.in);
		BufferedReader b =new BufferedReader(i);
		FileWriter f =  new FileWriter("File1.txt");
		BufferedWriter  w= new BufferedWriter(f);
		String s;
		while  ( true )
		{
			System.out.print("input a string");
			System.out.flush();
				s  =  b.readLine();
				if  ( s.length()  ==0 )
				break;
				w.write(s);
				w.newLine();
		}
			w.close();

	}

}

你可能感兴趣的:(java 输入输出-课堂作业7-6)