Last active
December 28, 2016 16:41
-
-
Save fbukevin/2d70772f6d52383dc748fa3d0d1a3139 to your computer and use it in GitHub Desktop.
Load general text file in Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String loadText(Context cxt, String file){ | |
String text = ""; | |
try{ | |
InputStream is = cxt.getAssets().open(file); | |
int size = is.available(); | |
byte[] buffer = new byte[size]; | |
is.read(buffer); | |
is.close(); | |
text = new String(buffer, "UTF-8"); | |
} catch(IOException ex){ | |
ex.printStackTrace(); | |
} | |
return text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment