I have a file in my assets folder... how do I read it?
Now I\'m trying:
public static String readFileAsString(String filePath)
throws j
BufferedReader's readLine() method returns a null when the end of the file is reached, so you'll need to watch for it and avoid trying to append it to your string.
The following code should be easy enough:
public static String readFileAsString(String filePath) throws java.io.IOException
{
BufferedReader reader = new BufferedReader(new FileReader(filePath));
String line, results = "";
while( ( line = reader.readLine() ) != null)
{
results += line;
}
reader.close();
return results;
}
Simple and to-the-point.