package io;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;
public class text3_2 {
/**
* 将键盘录入的数据拷贝到当前项目下的text.txt文件中,键盘录入数据当遇到quit时就退出
*
* @throws IOException
*/
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
String s = "";
FileOutputStream fos = new FileOutputStream("text.txt");
while (true) {
s = sc.next();
if (s.equals("quit")) {
break;
}
fos.write(s.getBytes());
fos.write("\r\n".getBytes());
}
fos.close();
}
}
|