I have the following code snippet to read the full contents of a text file into a string. It works, only problem is... it's really slow (the file is about 1500 lines long).
InputStream is = this.getResources().openRawResource(R.raw.comp_rules_glossary);
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String previousLine = "start";
while ((readLine = br.readLine()) != null)
{
rules = rules + readLine + eol;
if (previousLine.equals(""))
{
content = content + readLine + eol;
}
previousLine = readLine;
}
is.close();
br.close();
At the moment, I'm reading the full file in one line at a time, then appending it to the string. Is there a faster way to do this? I'm looking for a quick way to get the entire file into a string.