从文件读取文本
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; //nowjava.com - 时代Java public class Main { public void main(String[] argv) { try { BufferedReader in = new BufferedReader(new FileReader("infilename")); String str; while ((str = in.readLine()) != null) { System.out.println(str); } in.close(); } catch (IOException e) { } } } /** 来自 时代Java公众号**/