代码如下:
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();
}
}
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();
}
}
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();
}
stuOut.write(count);//要写byte
是什么意思