FileOutputStream fos = new FileOutputStream("google.html");更改为:
File userHome = new File(System.getProperty("user.home"));File pageOutput = new File(userHome, "google.html");FileOutputStream fos = new FileOutputStream(pageOutput); //see alternative below理想情况下,您可以将输出放在以下任意一个中:
- 的 子目录 (可能基于主类的包名称-避免冲突)
user.home
。user.home
是应该使用户能够读取和创建文件的地方。 - 最终用户在的帮助下指定的路径
JFileChooser
。



