1
CSVReader
을 사용하지 않고 CSV 파일을 JTable
으로 어떻게 가져올 수 있습니까? 현재 스캐너를 사용하고 있지만 CSV 파일의 데이터를 Object[][]
으로 가져오고 있습니다.CSV 파일을 CSVReader없이 JTable에 가져 오기
CSVReader
을 사용하지 않고 CSV 파일을 JTable
으로 어떻게 가져올 수 있습니까? 현재 스캐너를 사용하고 있지만 CSV 파일의 데이터를 Object[][]
으로 가져오고 있습니다.CSV 파일을 CSVReader없이 JTable에 가져 오기
귀하는 다음과 같이 할 수 있습니다.
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