If you want to read some file from assest folder of your project then first you have to get assest folder file named read.txt.
InputStream class is used to read data or content from file, network or from memory, we can also use this input stream with BufferedInputStream to do bulk reads may omit buffering.
Then after reading all bytes from text file we can write contents on any textview like this :
try {
InputStream inputStream = getAssets().open("readfilename.txt");
int size = inputStream.available();
byte[] buffersBytes = new byte[size];
inputStream.read(buffersBytes);
inputStream.close();
String text = new String(buffersBytes);
TextView tv = (TextView)findViewById(R.id.text);
tv.setText(text);
} catch (IOException e) {
throw new RuntimeException(e);
}
0 Comment(s)