Read binary file (docx, jpg) line by line java
<p>Here is my code:  </p>

<p>I get the <code>file</code> with a file chooser</p>

<pre><code>BufferedReader br = null;
BufferedReader reader;
try {
    reader = new BufferedReader(new FileReader(file));
    lines = 0;
    while (reader.readLine() != null) lines++;
    reader.close();
    } catch (FileNotFoundException e1) {
        e1.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    String[] wholeFile = new String[lines];
    try {
        String sCurrentLine;
        br = new BufferedReader(new FileReader(file));
        int counter = 0;
        while ((sCurrentLine = br.readLine()) != null) {
            String decode = Decode(sCurrentLine);
            System.out.println(decode);
            wholeFile[counter] = decode;
            counter++;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
</code></pre>

<p>If I save the file line by line it can't be opened properly (Word says it's damaged).<br>
Should I use other character encoding?  </p>