哈哈哈哈妈呀写了个死循环Pretty爽

  留念:

  

  不但死循环而且还忘了调用close(),一个进程吃了一半内存,然后我还直接把eclipse关了导致进程结束不了,文件也不能删,一删就提醒正在使用,然后文件大小就从20M蹭蹭地涨到3G哈哈哈哈哈  代码:

 1 import java.io.*;
 2 
 3 public class test {
 4     public static void main(String[] args) {
 5         File file = new File("src/test/test.txt");
 6         FileWriter output = null;
 7         
 8         try {
 9             output = new FileWriter(file);
10             
11             int i = 0;
12             double number;
13             String content;
14             while (i < 10) {
15                 number = (int) (Math.random() * 100) / 100.0;
16                 content = String.valueOf(number);
17                 output.write(content + " ");
18                 i++;
19             }
20         } catch (IOException e) {
21             System.out.println("错啦!你问错哪我也不知道呀!");
22             e.printStackTrace();
23             System.exit(-1);
24         }
25         
26         try {
27             output.close();
28         } catch (IOException e) {
29             e.printStackTrace();
30             System.exit(-1);
31         }
32         System.out.println("写入完毕。");
33     }
34 }
已修改

 

posted @ 2013-12-09 09:10  Chihane  阅读(87)  评论(1编辑  收藏  举报