我如何从文件中读取和拆分数据但在 Java 中也忽略了一些数据

How can I read and split data from file but Ignoring some data too in Java

我不知道如何解释这个,但我有这样的数据

1   John    US  38  24  090921
2   Dave    UK  29  12  043721
3   James   US  31  87  823874

tab分隔的数据,我只想这样读取我的数据

1   John    US  38
2   Dave    UK  29
3   James   US  31

我怎样才能在 Java 中做到这一点?你也能给我看代码示例吗?谢谢。

我想这对你的情况会有帮助。

BufferedReader in = null;
try {
    in = new BufferedReader(new FileReader("filename"));
    String read = null;
    while ((read = in.readLine()) != null) {
        String[] splited = read.split("\s+");
        for (String part : splited) {
            System.out.println(part); // to read the data is inputted correctly or not
        }
    }
} catch (IOException e) {
    System.out.println("There was a problem: " + e);
    e.printStackTrace();
} finally {
    try {
        in.close();
    } catch (Exception e) {
    }
}