title: Java Jar file: use resource errors: URI is not hierarchical
body: <p>I have deployed my app to jar file. When I need to copy data from one file of resource to outside of jar file, I do this code:</p>
  
  <pre><code>URL resourceUrl = getClass().getResource("/resource/data.sav");
  File src = new File(resourceUrl.toURI()); //ERROR HERE
  File dst = new File(CurrentPath()+"data.sav");  //CurrentPath: path of jar file don't include jar file name
  FileInputStream in = new FileInputStream(src);
  FileOutputStream out = new FileOutputStream(dst);
   // some excute code here
  </code></pre>
  
  <p>The error I have met is: <code>URI is not hierarchical</code>. this error I don't meet when run in IDE.</p>
  
  <p>If I change above code as some help on other post on StackOverFlow:</p>
  
  <pre><code>InputStream in = Model.class.getClassLoader().getResourceAsStream("/resource/data.sav");
  File dst = new File(CurrentPath() + "data.sav");
  FileOutputStream out = new FileOutputStream(dst);
  //....
  byte[] buf = new byte[1024];
  int len;
  while ((len = in.read(buf)) &gt; 0) { //NULL POINTER EXCEPTION
    //....
  }
  </code></pre>