Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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
         }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java string format thousand separator 
Java :: HttpServer example java 
Java :: java argument main 
Java :: at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1565) 
Java :: java double format 
Java :: how to create a stack data structure in java? 
Java :: n queens problem leetcode 
Java :: start fragment from activity 
Java :: how to convert epoch time to date in java 
Java :: slice a list java 
Java :: input char java 
Java :: java divisible by operator 
Java :: replace last char in string java 
Java :: initialize class java 
Java :: convert fahrenheit to celsius 
Java :: how to add input in array java 
Java :: java map to list or array 
Java :: java 8 find in list by property 
Java :: for loop java 
Java :: java list distinct by attribute 
Java :: input array in String in java 
Java :: junit vintage engine maven 
Java :: permutation array java 
Java :: 8.1.1. Declaring an Array¶ 
Java :: implement the bubble sort algorithm on the following arraylist 
Java :: Printing array list through for loop in java 
Java :: discord jda 
Java :: for each loop java 
Java :: resize image icon to fit jlabel 
Java :: java append file 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =