Java 读本地文件

 1         java.io.BufferedReader reader = new java.io.BufferedReader(
 2                 new java.io.FileReader("d:/testfile.txt"));
 3         String s = reader.readLine();
 4         StringBuffer sb = new StringBuffer();
 5         while (s != null) {
 6             sb.append(s);
 7             sb.append("\r\n");
 8             s = reader.readLine();
 9         }
10         System.out.println(sb.toString());
11         reader.close();
12         String x = sb.toString();

 

posted @ 2013-11-18 09:34  Shaman  阅读(465)  评论(0编辑  收藏  举报