[color=red]
[size=xx-large]以下是最终版(问题已经解决)[/size]
[/color]
[size=xx-large]以下是最终版(问题已经解决)[/size]
[/color]
package cn.com.flows;
import java.io.*;
import java.util.*;
/**
* @author k1280000
*
*/
public class KeyboardInputTest {
public static void main(String[] args) throws IOException {
//键盘输入,并打印
// BufferedReader fi = new BufferedReader (new InputStreamReader (System.in));
// System.out.println("please input : ");
// String s=fi.readLine();
// while(!s.equals("exit")){
// System.out.println(s);
// s=fi.readLine();
// }
//键盘输入,输出到文件
File outputfile = new File ("D:\\Program Files\\Eclipsjava\\workplace\\Anewstart\\src\\cn\\com\\flows\\d.txt");
BufferedReader fi = new BufferedReader (new InputStreamReader (System.in));
PrintWriter fo = new PrintWriter(outputfile,"utf-8"); //此处要设置实行UTF-8 编码才能解决输入中文时的一些乱码问题
System.out.println("please input : ");
String s1 = "";
String s=fi.readLine();
while(!s.endsWith(".")){
// System.out.println(s);
s+="\r"+"\n"; //这里的\r \n 可以防止输入的是中文的话的乱码问题
s1 += s;
s=fi.readLine();
}
s1 += s;
fo.write(s1);
fo.flush(); //在此处的作用非常明显,不用的话,没填满,不会输出到文件,所以文件中也不会有内容
System.out.println();
fi.close();
fo.close();
}
}