gpt4 book ai didi

java - 读取.txt 文件中的特定列???我需要运行一个特定的专栏

转载 作者:行者123 更新时间:2023-12-01 17:22:32 24 4
gpt4 key购买 nike

文本文件内容如下:

**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]);
}
}

关于java - 读取.txt 文件中的特定列???我需要运行一个特定的专栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61267252/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com