日期:2014-05-20 浏览次数:20731 次
import java.util.*;
import java.io.*;
public class JavaScanner
{
public static void main(String[] args)
{
File file=new File("c:/content.txt");
try
{
Scanner in=new Scanner(file);
String str;
while(true)
{
if(in.hasNext())
{
str=in.next();
System.out.println(str);
}
else
{
System.out.println("No content.");
break;
}
}
in.close();
}
catch(FileNotFoundException e)
{
System.out.println("File not found.");
}
}
}