Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>With <code>ObjectOutputStream</code> you're basically <a href="http://download.oracle.com/javase/1,5.0/docs/guide/serialization/index.html" rel="nofollow">serializing</a> a <code>String</code> <strong>object</strong> to the output. The result is <strong>not</strong> a human readable text file with string's original value.</p> <p>You need to use a <code>Writer</code> wherein you pass the string's value to.</p> <pre><code>public void writeStream() throws IOException { Writer writer = new FileWriter("outputOne.txt"); try { writer.write(inputContent); } finally { writer.close(); } } </code></pre> <p>This will end up in a human readable text file with the string's original value.</p> <hr> <p><strong>Unrelated</strong> to the concrete problem, please note that using relative paths in file IO is an extremely bad idea. You never know for sure where it will end up and in some environments the working directory is not writable as well. Always explicitly specify an absolute path to an existing and writable folder:</p> <pre><code> Writer writer = new FileWriter("/path/to/outputOne.txt"); </code></pre> <p>In Windows environments where the server is installed and executed from the <code>C:\</code> disk, the above path is basically the same as <code>C:\path\to\outputOne.txt</code>. You can if necessary configure the folder root as VM argument or configuration file setting. Assuming that you pass <code>-Doutput.location=/path/to</code> VM argument, then you could use it as follows:</p> <pre><code> File root = new File(System.getProperty("output.location")); Writer writer = new FileWriter(new File(root, "outputOne.txt")); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload