I have a .doc
file saved on my sdcard. I need to read the content of .doc
file and show it in a TextView
.
Can any
Sorry my mistake. You need to do this.
public void onCreate(Bundle b) {
super.onCreate(b);
setContentView(R.layout.main);
String extPath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.Separator;
InputStream inputStream = assetManager.open(extPath + "file.doc");
String text = loadFile(inputStream);
TextView tv = (TextView) findViewById(R.id.txtv);
tv.setText(text);
}
public String loadFile(InputStream inputStream) {
ByteArrayOutputStream b = new ByteArrayOutputStream();
byte[] bytes = new byte[4096];
int length = 0;
while () {
b.write(bytes, 0, length);
}
return new String(b.toByteArray(), "UTF8");
}