I am loading a file,
getting a line from it
and putting it in a jTable
the jTable shows some of my charcters as square boxes.
answers I found online:
1.
- it's how the file is opened, so I changed
BufferedReader bf = new BufferedReader(new FileReader(filename));
- into
BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "UTF8"));
- I also tried Charset instead of the string
2.
- it's the font, so I tried
jTable1.setFont(new Font("Times New Roman", Font.BOLD, 12));
- I tried other fonts, like Arial, David, ...
Can you think of any other reason??
By nachokk's request, here's my code:
int linecount = 0;
String line = null;
BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "UTF8"));
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
while ((line = bf.readLine()) != null) {
linecount++;
model.addRow(new Object[]{filename, linecount, line});
}