swing - jTable Encoding in Java -


i loading file,

getting line

and putting in jtable

the jtable shows of charcters square boxes.

answers found online:

1.

  • it's how file opened, changed
  • bufferedreader bf = new bufferedreader(new filereader(filename));
  • into
  • bufferedreader bf = new bufferedreader(new inputstreamreader(new fileinputstream(filename), "utf8"));
  • i tried charset instead of string

2.

  • it's font, tried
  • jtable1.setfont(new font("times new roman", font.bold, 12));
  • i tried other fonts, arial, david, ...

can think of other reason??

by nachokk's request, here's 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});         } 

you box on screen when use font doesn't contain necessary glyphs (i.e. doesn't know how render unicode character codes).

if java couldn't read file (i.e. encoding issues), should see ? instead.

if need quick test, open text editor allows select fond , your os's unicode input method enter unicode values (or, if have file, try open it).

note word processors notice when glyph missing , automatically fall font contains glyph.

[edit]

it gives me replacement character 65533 @ every location

that means use wrong encoding read file. find out correct encoding (ask people create it, example) , use instead of utf-8


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -