Java通過java.io.FileInputStream讀取txt文本
package com;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class TestIO {
public static void main(String[] args) {
FileInputStream in = null;
try {
in = new FileInputStream("test.txt");
int c;
c = in.read();
while (c != -1) {
System.out.print((char) c);
c = in.read();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
System.out.println(e.getMessage());
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
其中test.txt內為英文字符串,放在eclipse項目文件夾根目錄下,對於中文需要做編碼處理。
Java 8 中 HashMap 的性能提升 http://www.linuxidc.com/Linux/2014-04/100868.htm
Java 8 的 Nashorn 引擎 http://www.linuxidc.com/Linux/2014-03/98880.htm
Java 8簡明教程 http://www.linuxidc.com/Linux/2014-03/98754.htm