编写一个JAVA程序,将自己的个人信息(学号、姓名、性别等)保存到c:\myinfo.txt文件中。 20
1个回答
展开全部
import java.io.*;
import java.util.*;
/**
* @author hardneedl
*/
public class SaveFileDemo {
public static void main(String... args) throws FileNotFoundException {
Scanner scanner = new Scanner(System.in);
String[] questions = new String[]{
"姓名",
"学号",
"性别"
};
PrintWriter writer = new PrintWriter("myinfo.txt");
for (String q : questions){
System.out.println(q);
writer.print(q);
String a = scanner.next();
writer.println(a);
}
writer.close();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询