Skip to content

Instantly share code, notes, and snippets.

@Shajeel-Afzal
Created August 16, 2013 16:12
Show Gist options
  • Save Shajeel-Afzal/6251251 to your computer and use it in GitHub Desktop.
Save Shajeel-Afzal/6251251 to your computer and use it in GitHub Desktop.
I am creating my first Gist. I am at learning level of Gist. I have quickly copied the following code from somewhere.
// Get raw spanned text
Resources res = getResources();
BufferedReader input = new BufferedReader(new InputStreamReader(
res.openRawResource(R.raw.get_accounts)));
StringBuffer sb = new StringBuffer();
try {
String line;
while ((line = input.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Spanned spannedCode = Html.fromHtml(sb.toString());
((TextView)findViewById(R.id.code_sample)).setText(spannedCode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment