how to read file from assets folder in android
BufferedReader reader = null;
try {
reader = new BufferedReader(
new InputStreamReader(getAssets().open("filename.txt"), "UTF-8"));
// do reading, usually loop until end of file reading
String mLine;
while ((mLine = reader.readLine()) != null) {
//process line
...
}
} catch (IOException e) {
//log the exception
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
//log the exception
}
}
}
Also in Java:
- http client java
- int to long java
- vector in java
- java hello world
- java math.random
- java int stream min
- android java add new record to Firebase Firestore
- Unrecognized option: --version Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
- java list contains object with property
- output statement java
- org.springframework.orm.jpa.EntityManagerHolder cannot be cast to org.springframework.orm.hibernate5.SessionHolder
- sum of arraylist java 8
- how to check if an arraylist contains a value in java recursion
- absolute value in java
- iterate over map keys java
- isnumber java
- caesar cipher java
- split every character in string into array java
- java remove double spaces
- java stream to list
- java count substring occurrences in string
- android hide and show bottom navigation
- processing audio android
- how to set a variable java