//运用bufferreader读取,按行读取并且按照空格为界拆分后保存到数组result中,然后输出。
//将bufferreader写入try中就不用关闭文件了。哈哈哈
package home;
import java.io.*;public class ReadAfile {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try(BufferedReader reader = new BufferedReader (new FileReader("D://stu.txt")))
{
String line=null;
while((line=reader.readLine())!=null){
String []result=line.split(" ");
for (String token:result){
System.out.println(token);
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
}