Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UTF-8 in a JTable

Tags:

java

swing

jtable

How can I add UTF-8 Strings into a JTable? Strings in the ASCII range look ok, but characters that have accents aren't showing up properly.

like image 365
Anonymous1 Avatar asked Mar 14 '26 10:03

Anonymous1


1 Answers

I was reading in the strings without setting the reader to a UTF-8 encoding. After changing

BufferedReader br = new BufferedReader(new InputStreamReader(di));

to

BufferedReader br = new BufferedReader(new InputStreamReader(di, "UTF-8"));

the text showed up correctly.

like image 131
Anonymous1 Avatar answered Mar 16 '26 23:03

Anonymous1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!