河南成教 / 河南理工大学
21[分析题]
import java.io.*;
public class TestFile
{
public static void main(String args[]) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in);
BufferedWriter bw = new BufferedWriter(new FileWriter(“input.txt");
String s;
while (true)
{
System.out.print("请输入一个字符串: ");
System.out.flush();
s=br.readLine();
if (s.length()==0) break;
bw.write(s);
bw.newLine();
}
bw.close();
}
}
21[分析题]
import java.io.*;
public class TestFile
{
public static void main(String args[]) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in);
BufferedWriter bw = new BufferedWriter(new FileWriter(“input.txt");
String s;
while (true)
{
System.out.print("请输入一个字符串: ");
System.out.flush();
s=br.readLine();
if (s.length()==0) break;
bw.write(s);
bw.newLine();
}
bw.close();
}
}
参考答案: