【正确答案】import java.io.*;
public class InFile{
public static void main(String[] args)
{
int ch;
try{
FileOutputStream out=new FileOutputStream("a.txt");
while((ch=System.in.read())!='/r'){
System.out.write(ch);
out.write(ch);
}
out.close();
System.out.write('/n');
}catch(IOException e){
System.out.println(e.toString());
}
System.out.println("输出至文件完毕!");
}
}
【答案解析】