Code
Public String getFromAssets (String fileName ){
Try {
InputStreamReader inputReader = new InputStreamReader (getResources (). getAssets (). open (fileName ));
BufferedReader bufReader = new BufferedReader (inputReader );
String line = "";
String Result = "";
While (line = bufReader. readLine ())! = Null)
Result + = line;
Return Result;
} Catch (Exception e ){
E. printStackTrace ();
}
}
// Obtain the file from the assets folder and read the data
Public String getFromAssets (String fileName ){
String result = "";
Try {
InputStream in = getResources (). getAssets (). open (fileName );
// Obtain the object Byte Count
Int lenght = in. available ();
// Create a byte array
Byte [] buffer = new byte [lenght];
// Read the data in the file to the byte array
In. read (buffer );
Result = EncodingUtils. getString (buffer, ENCODING );
} Catch (Exception e ){
E. printStackTrace ();
}
Return result;
}
}