Search code examples
javaandroidarabic

Android - How to read txt file in JAVA


Please Will some one help me out i am trying to read an Arabic .txt file and it always give me the Arabic word like this "????? ???"

private String ReadArabic() {

    String words="";
    try {
        InputStream stream = getAssets().open("arabwords.txt");

        int size = stream.available();
        byte[] buffer = new byte[size];
        stream.read(buffer);
        stream.close();
        words = new String(buffer, "UTF-8");
        words = words.replaceAll("(\\r|\\n)", "");
    } catch (IOException e) {
        // Handle exceptions here
    }
    return words;
}

Solution

  • Try using: "cp864" instead of "UTF-8"