我正在尝试在 jTable 中加载一个 .csv 文件。在记事本中,文件显示 OK,但在 jTable 中,一些字符(如“£”、“$”)变成了一个框。
private void parseUsingOpenCSV(String filename){
DefaultTableModel model = (DefaultTableModel) empTbl.getModel();
int rows = model.getRowCount();
if (rows>0){
for(int i=0 ; i<rows; i++)
{model.removeRow(0);}
}
try {
CSVReader reader = new CSVReader(new FileReader(filename));
String [] nextLine;
int rowNumber = 0;
while ((nextLine = reader.readNext()) != null) {
rowNumber++;
model.addRow(new Object[]{nextLine[0], nextLine[1], nextLine[2], nextLine[3], nextLine[4], nextLine[5], nextLine[6], nextLine[7]});
}
} catch (IOException e) {
System.out.println(e);
}
}
我怎么解决这个问题 ?