27 9月 2007

[Java] 讀檔 對字串切Token

讀檔 對字串切Token

    String fileName = "xxx.txt";

FileReader fr = new FileReader( fileName );//讀檔

BufferedReader stdin = new BufferedReader( fr );
//將fr置入BufferedReader, 只有BufferedReader能readLine()



StringTokenizer stoken = null;

while( stdin.ready() ){

stoken = new StringTokenizer( stdin.readLine() );

while( stoken.hasMoreTokens() ){
System.out.println( stoken.nextToken() );
}
}
 

沒有留言: