Search code examples
androidutf-8inputstreamassets

Read a textfile in assets containing åäö


I am having some problems reading text from a file in my assets folder.
Its doesn't want to show åäö at all, I have used this code that I have found in different StackOverflow posts, but it won't work. I only get "?" instead

Here is the code:

public void loadQuestions() throws IOException {
    atStart = false;

    InputStreamReader reader = new InputStreamReader(getAssets().open("questions.txt"), "UTF-8");
    BufferedReader br = new BufferedReader(reader); 
    String line = br.readLine();
    while (line != null) {
        Log.d("TAG", line);
        questions.add(line);
        line = br.readLine();
    }
}

Solution

  • I found the problem myself.
    When I save my textfile I have to save it with an encoding of UTF-8 and not with ANSI.