Java 不使用CSVReader将CSV文件导入JTable
如何在不使用Java 不使用CSVReader将CSV文件导入JTable,java,swing,jframe,jtable,Java,Swing,Jframe,Jtable,如何在不使用CSVReader的情况下将CSV文件导入JTable。我目前正在使用扫描仪,但我一直在将数据从CSV文件获取到对象[][]您可以这样做 ArrayList<String[]> data = new ArrayList<String[]>(); while( myScanner.hasNextLine()) { //get one row String oneRow = myScanner.nextLine(); //then s
CSVReader
的情况下将CSV文件导入JTable
。我目前正在使用扫描仪,但我一直在将数据从CSV文件获取到对象[][]
您可以这样做
ArrayList<String[]> data = new ArrayList<String[]>();
while( myScanner.hasNextLine()) {
//get one row
String oneRow = myScanner.nextLine();
//then split the line by comma
String[] oneSplitRow = oneRow.split(",");
//add your data to the arraylist
data.add(oneSplitRow);
}
// now to make the Object[][]
Object[][] theData = new Object[data.size()][data.get(0).length];
// and here is where you can iterate through the data arraylist and put
// the strings into theData 2d array
// ..... your code here
ArrayList data=new ArrayList();
while(myScanner.hasNextLine()){
//排一行
字符串oneRow=myScanner.nextLine();
//然后用逗号分隔行
字符串[]oneSplitRow=oneRow.split(“,”);
//将数据添加到arraylist
data.add(oneSplitRow);
}
//现在,让对象[][]
Object[][]theData=新对象[data.size()][data.get(0.length];
//在这里,您可以迭代数据数组列表并将
//将字符串插入数据2d数组
// ..... 你的代码在这里
您可以这样做
ArrayList<String[]> data = new ArrayList<String[]>();
while( myScanner.hasNextLine()) {
//get one row
String oneRow = myScanner.nextLine();
//then split the line by comma
String[] oneSplitRow = oneRow.split(",");
//add your data to the arraylist
data.add(oneSplitRow);
}
// now to make the Object[][]
Object[][] theData = new Object[data.size()][data.get(0).length];
// and here is where you can iterate through the data arraylist and put
// the strings into theData 2d array
// ..... your code here
ArrayList data=new ArrayList();
while(myScanner.hasNextLine()){
//排一行
字符串oneRow=myScanner.nextLine();
//然后用逗号分隔行
字符串[]oneSplitRow=oneRow.split(“,”);
//将数据添加到arraylist
data.add(oneSplitRow);
}
//现在,让对象[][]
Object[][]theData=新对象[data.size()][data.get(0.length];
//在这里,您可以迭代数据数组列表并将
//将字符串插入数据2d数组
// ..... 你的代码在这里