title: IllegalStateException: zip file closed during file write
body: <p>This bug occurs when my program enters the shutdown hook and tries to write the settings file to a text document.  The strange thing is, it doesnt throw an exception everytime.</p>
  
  <pre><code>Exception in thread "Thread-4" java.lang.IllegalStateException: zip file closed
      at java.util.zip.ZipFile.ensureOpen(Unknown Source)
      at java.util.zip.ZipFile.getEntry(Unknown Source)
      at java.util.jar.JarFile.getEntry(Unknown Source)
      at java.util.jar.JarFile.getJarEntry(Unknown Source)
      at com.crimson.server.JarClassLoader.findJarEntry(JarClassLoader.java:514)
      at com.crimson.server.JarClassLoader.findJarClass(JarClassLoader.java:584)
      at com.crimson.server.JarClassLoader.loadClass(JarClassLoader.java:956)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at com.crimson.universalUtils.Datastore.store(Datastore.java:66)
      at com.crimson.server.ServerShutdownHook.run(ServerShutdownHook.java:38)
  </code></pre>
  
  <p>Here is Datastore.store(Settings):</p>
  
  <pre><code>public static File set = new File("settings.properties");
  
  public static void store(Settings settings){
      set.delete();
  
      try {
          set.createNewFile();
          PrintWriter pw = new PrintWriter(set);//line 66
          pw.println(ObjectTransfer.toString(settings));
  
          pw.close();
      } catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
  }
  </code></pre>
  
  <p>I dont know why creating the PrintWriter calls ClassLoader.loadClass, but that could be the problem because im using JarClassLoader: <a href="http://www.jdotsoft.com/JarClassLoader.php" rel="nofollow">http://www.jdotsoft.com/JarClassLoader.php</a></p>