I want to read a .txt, .doc and .docx files and print the contents of those files.when i run the below code some .doc and .txt files are read but many files are not able to read.

```
import java.io.File;
import javax.swing.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;

public class FindYourDocx 
{

    public static void main(String[] args) 
    {
String text = "";
    int read, N = 1024 * 1024;
    char[] buffer = new char[N];

    try { 
        JFileChooser openFile=new JFileChooser();
             openFile.setCurrentDirectory(new File("."));
             openFile.showOpenDialog(null);
            File f1=openFile.getSelectedFile();
           String file1=f1.toString();
           File f =new File(file1);
           JOptionPane.showMessageDialog(null,f);
        FileReader fr = new FileReader(f);
        BufferedReader br = new BufferedReader(fr);

        while(true) {
            read = br.read(buffer, 0, N);
            text += new String(buffer, 0, read);
        System.out.println("Follows"+text+" "); 
                    if(read < N) {
                break;
            }
       System.out.println("Follows"+text+" "); }
    } catch(Exception ex) {
        ex.printStackTrace();
    }

    }}

```

by executing the above code (for some files) i got some wired messages as follows  

<http://i.stack.imgur.com/RwNWM.jpg>

Someone please help me to solve this issues....

to read .docx i came across something like XWPFDocument using apacheio ....what is this ?