Search code examples
androidtextinputstream

Inputstream, Can't read commas ' or quotes "" in android


I am trying to read a text file from raw folder, and it works perfectly except for one problem.

The problem is for any quotes " ", or Commas ' in the text file, it displays this question mark symbol instead.

code:

try {
        Resources res = getResources();
        InputStream in_s = res.openRawResource(R.raw.hr_consultant);

        byte[] b = new byte[in_s.available()];

        
        in_s.read(b);

        tv_data.setText(new String(b));
    } catch (Exception e) {
        // e.printStackTrace();
        tv_data.setText("Error: can't show help.");
    }

N.B: the text file in raw is referred as int value, so another Reader types may not work. so any ideas?


Solution

  • When you done with your text file;

    • Select File > Save As
    • Edit "Encoding" property to UTF-8