Note that there are some explanatory texts on larger screens.

plurals
  1. POWrite object to file not working
    primarykey
    data
    text
    <p>I have the following code: </p> <pre><code>public static void logMessage(Object msg) { if (outputStream != null) { try { outputStream.writeObject(msg); outputStream.flush(); } catch (IOException e) { ErrorPopUp.setMessage( e.toString()).setVisible(true); } } else { if ((logDirectory != null) &amp;&amp; (writeLogName != null)) { try { setWriteFileName(writeLogName); outputStream.writeObject(msg); outputStream.flush(); } catch (IOException e) { ErrorPopUp.setMessage( e.toString()).setVisible(true); } } else { ErrorPopUp.setMessage("Log file name not set!").setVisible(true); } } } </code></pre> <p>and</p> <pre><code>private static boolean setWriteFileName(String name) throws IOException { writeLogName = name; if (logDirectory != null) { try { writeLogFile = new File(name); writeLogFile.createNewFile(); outputStream = new ObjectOutputStream( new BufferedOutputStream( new FileOutputStream( writeLogFile))); return true; } catch (IOException e) { throw e; } } else { ErrorPopUp.setMessage("Log directory name not set!").setVisible(true); return false; } } </code></pre> <p>Using this, the File gets created like I expect it to do, but nothing gets written into it.<br> I'm pretty sure it's something obvious that I'm missing because I'm looking to long at the code ;)<br> I really would appreciate some advise.</p> <hr> <p><strong>EDIT:</strong></p> <pre><code>public static void stopLogging() { try { if(outputStream != null){ outputStream.close(); } } catch (IOException e) { ErrorPopUp.setMessage(e.toString()).setVisible(true); } if(writeLogFile != null){ writeLogFile.setReadOnly(); } outputStream = null; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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