Skip to main content
improved formatting
Source Link
cheffe
  • 9.5k
  • 3
  • 49
  • 58

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:

 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 

The error I have met is: URI is not hierarchical. this error I don't meet when run in IDE.

If I change above code as some help on other post on StackOverFlow:

 InputStream in = Model.class.getClassLoader().getResourceAsStream("/resource/data.sav");  File dst = new File(CurrentPath()+"data + "data.sav");  FileOutputStream out = new FileOutputStream(dst);  //....  byte[] buf = new byte[1024];  int len;  while ((len = in.read(buf)) > 0) { //NULL POINTER EXCEPTION  //....  } 

Please help me fix this.

Thanks :)

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:

 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 

The error I have met is: URI is not hierarchical. this error I don't meet when run in IDE.

If I change above code as some help on other post on StackOverFlow:

 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)) > 0) { //NULL POINTER EXCEPTION //....  } 

Please help me fix this.

Thanks :)

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:

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 

The error I have met is: URI is not hierarchical. this error I don't meet when run in IDE.

If I change above code as some help on other post on StackOverFlow:

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)) > 0) { //NULL POINTER EXCEPTION  //.... } 
deleted 2 characters in body
Source Link
kolossus
  • 20.7k
  • 3
  • 55
  • 109

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:

 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 

The error I have met is: URI is not hierarchical. this error I don't meet when run in IDE.

If I change above code as some help on other post on StackOverFlowStackOverFlow:

 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)) > 0) { //NULL POINTER EXCEPTION //.... } 

Please help me fix this.

Thanks :)

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:

 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 

The error I have met is: URI is not hierarchical. this error I don't meet when run in IDE.

If I change above code as some help on other post on StackOverFlow:

 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)) > 0) { //NULL POINTER EXCEPTION //.... } 

Please help me fix this.

Thanks :)

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:

 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 

The error I have met is: URI is not hierarchical. this error I don't meet when run in IDE.

If I change above code as some help on other post on StackOverFlow:

 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)) > 0) { //NULL POINTER EXCEPTION //.... } 

Please help me fix this.

Thanks :)

added 453 characters in body
Source Link
hqt
  • 30.4k
  • 54
  • 180
  • 256

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:

 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 

The error I have met is: URI is not hierarchical. this error I don't meet when run in IDE.

If I change above code as some help on other post on StackOverFlow:

 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)) > 0) { //NULL POINTER EXCEPTION //.... } 

Please help me fix this.

Thanks :)

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:

 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 

The error I have met is: URI is not hierarchical. this error I don't meet when run in IDE.

Please help me fix this.

Thanks :)

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:

 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 

The error I have met is: URI is not hierarchical. this error I don't meet when run in IDE.

If I change above code as some help on other post on StackOverFlow:

 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)) > 0) { //NULL POINTER EXCEPTION //.... } 

Please help me fix this.

Thanks :)

Source Link
hqt
  • 30.4k
  • 54
  • 180
  • 256
Loading