How to convert File to String and get back that String to File again
<p>I have a question: "How to convert File to String and get back that String to File again in Java?" </p>

<p>my code :</p>

<p>public static void main(String[]args) throws IOException{</p>

<pre><code>    String fff = fileToString("Book.xlsx");
    byte[] bytes = fff.getBytes();

    File someFile = new File("Book2.xlsx");
    FileOutputStream fos = new FileOutputStream(someFile);
    fos.write(bytes);
    fos.flush();
    fos.close();
}
public static String fileToString(String file) {
    String result = null;
    DataInputStream in = null;

    try {
        File f = new File(file);
        byte[] buffer = new byte[(int) f.length()];
        in = new DataInputStream(new FileInputStream(f));
        in.readFully(buffer);
        result = new String(buffer);
    } catch (IOException e) {
        throw new RuntimeException("IO problem in fileToString", e);
    } finally {
        try {
            in.close();
        } catch (IOException e) { /* ignore it */
        }
    }
    return result;
}
</code></pre>

<p>How I can getback Book1.xlsx in string and saved in book2.xlsx ?? Book2.xlsx is null....</p>
