文本文件内容如下:
**Name class Section School**
tin 10 a ysr
cane 9 a cik
morj 8 b vit
vel 7 d klm
此解决方案使用您提供的输入,但这是一个快捷的解决方案。这个解决方案对你来说足够好吗?还是你想要一个更好的解决方案?
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class FIrst {
public static void main(String[] args)throws Exception
{
File file = new File("data.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
String[] columnNames = null;
if ((st = br.readLine()) == null) {
System.out.println("did not find first line");
return;
}
while ((st = br.readLine()) != null)
System.out.println(st.split(" ")[3]);
}
}