代码如下:
import java.io.*;
public class Student {
public static void main(String[] args) throws IOException {
FileOutputStream stuOut = new FileOutputStream("StudentInfo.txt");
int count =0;
System.out.println("请输入姓名,学号和成绩:");
try {
while ((count = System.in.read()) != -1) {
//如何设置  当键入空字符时,程序停止
stuOut.write(count);
}
} catch (Exception e) {
}
stuOut.close();
}
}

解决方案 »

  1.   

        public static void main(String[] args) throws IOException {
            FileOutputStream stuOut = new FileOutputStream("StudentInfo.txt");
            int count = 0;
            System.out.println("请输入姓名,学号和成绩:");
            try {
                while ((count = System.in.read()) != -1) {
                    // 如何设置 当键入空字符时,程序停止,加上下面两句!
                    if (count <= ' ')
                        break;
                    stuOut.write(count);//要写byte
                }
            } catch (Exception e) {
            }
            stuOut.close();
        }
      

  2.   

    再问一下
     stuOut.write(count);//要写byte
    是什么意思