简体   繁体   English

JComboBox 包含来自文件中索引位置的数据 Java

[英]JComboBox containing data from index positions in a file Java

I have a text file as follows which contains data about items of stock.我有一个如下的文本文件,其中包含有关库存项目的数据。 Index position 1 of each line contains the name of the product.索引 position 每行 1 包含产品名称。 I want to be able to take that index position from each line in the file, and display it in a combobox, but I don't know how to do that.我希望能够从文件中的每一行获取索引 position,并将其显示在 combobox 中,但我不知道该怎么做。 I'm trying to use different classes too.我也在尝试使用不同的类。

This is the file as reference这是作为参考的文件

You can get the first item of each line using String.split :您可以使用String.split获取每行的第一项:

line.split(",", 3)[1]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM