I am trying to display the contents of .doc/.docx file in the textview in Android Activity by using the code.
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard,"demo.docx");
StringBuilder text = new StringBuilder();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
text.append(line);
text.append('\n');
}
br.close();
}
catch (IOException e) {
}
output.setText(text);
But, I am getting output like this,
https://i.stack.imgur.com/TAqCW.jpg
It works fine for .txt file but not for .doc/.docx file. Please Help me, how to display the contents of .doc/.docx file in textview in android activity?