扫描仪从文件中逐字读取
import java.io.*; import java.util.Scanner; public class ScanXan {/** n o w j a v a . c o m 提供 **/ public static void main(String[] args) throws IOException { Scanner s = null; try { s = new Scanner( new BufferedReader(new FileReader("xanadu.txt"))); while (s.hasNext()) { System.out.println(s.next()); } } finally { if (s != null) {/*来自 N o w J a v a . c o m - 时 代 Java*/ s.close(); } } } }