I would like to read the content of a file located in the Assets as a String. For example, a text document located in src/main/assets/
Original Question
I found that this question is mostly used as a 'FAQ' for reading an assets file, therefore I summarized the question above. Below is my original question
I'm trying to read a assets file as string. I have a file in my assets folder: data.opml, and want to read it as a string.
Some things I tried:
AssetFileDescriptor descriptor = getAssets().openFd("data.opml");
FileReader reader = new FileReader(descriptor.getFileDescriptor());
And also:
InputStream input = getAssets().open("data.opml");
Reader reader = new InputStreamReader(input, "UTF-8");
But without success, so a full example would be appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…