public class Test09 {public static void main(String[] args) throws Exception {File file = new File("E:\\upload\\note.txt");if (!file.exists()) {file.createNewFile();System.out.println("文件创建成功");}BufferedWriter bw =null;bw = new BufferedWriter(new FileWriter("E:\\upload\\note.txt"));Scanner sc = new Scanner(System.in);System.out.println("请输入一行字符串:");String str=sc.nextLine();System.out.println(str);bw.write(str);System.out.println("写入成功");bw.close();}
}
详细解决方案
建一个文件“note.txt“,然后通过控制台输入的每一行字符串都按行写入到 * note.txt中。当输入的字符串为“exit“时退出程序。
热度:85 发布时间:2023-12-02 06:00:01.0
相关解决方案
- MyEclipse错误:Java was started but returned exit code = 1
- Tornado远程调试的有关问题:Target Server will exit
- Andrew W. Davis’s 2013 prediction - Cisco will exit the hardware-based group video conferencing
- 错误信息:could not find the main class programe will exit
- java中窗口退出时System.exit(0)和System.exit(1)有什么区别?
- [求助]exit(5)是什么意思
- [求助]exit(5)是什么意思
- if isempty(menu(i,j)) then exit for 这句是什么意思?解决方法
- CSS Note 一
- PHP的几个程序停止关键字break,return,exit
- 封装RCP ,运行出现 JVM terminated Exit code=13
- JS + JQUERY > note 一
- note.js,该怎么解决
- 请问html中<a href=Note?status=selectall>的含义
- could not find the main class.Program will exit,该如何处理
- Myeclipse6.5频繁自动弹出,异常:JVM terminated. Exit code=1
- Myeclipse 异常:JVM terminated. Exit code=255
- Myeclipse 启动时报错:JVM terminated.Exit.code = -一
- eclipse启动异常:java was started but returned exit code = 1
- 关于eclipse"JVM terminated. Exit code=-1"这个有关问题
- 解决eclipse3.5 起步报错 JVM terminated. Exit code=-1
- Eclipse 3.5 中的jvm terminated.Exit code=-1异常的解决
- eclipse jvm terminated. exit code 1 解决办法
- Eclipse起步失败 terminated Exit code=-1
- Fedora 12 eclipse 起步失败 JVM terminated. Exit code=-1
- Eclipse不能起动:JVM terminated. Exit code=-1解决
- eclipse-jee-galileo-SR2-win32中的jvm terminated.Exit code=-1异常的解决
- eclipse 没法启动 JVM terminated. Exit code=-1
- 解决Eclipse启动异常 jvm terminated. exit code 1
- eclipse异常java was started but returned exit code =-805306369