mport java.io.FileNotFoundException;
import java.util.Scanner;
/**
* @Author <a href="felayman@163.com">方磊</a>
* @Time 2014-2-7
*/
public class ScannerDemo {
public static void main(String[] args) throws FileNotFoundException {
Scanner sc = new Scanner(
new File(
"C:\\Users\\falay\\Desktop\\Java_Start_End\\JavaCore\\src\\hello.txt"));
StringBuffer buffer = new StringBuffer();
while (sc.hasNext()) {
buffer.append(sc.next());
}
System.out.println(buffer);
}
}
|