0

HELLO I made a video plays on a panel

and I get the video's url by this :

URL urlWaterIntake = new URL("file:///c:/tmp/water.avi");

BUT I moved the 'tmp' folder inside the 'bin' folder of eclipse IDE , and now i access by this :

URL urlWaterIntake = new URL("file:///tmp/water.avi");

AND ERRORR !!! voila !! what a life ... , some solutions ??

btw i tried this one too :

File myFile = new File("tmp/water.avi");
URL urlWaterIntake = new URL(myFile.toURI().toURL());

BUT NOTHING WORKS.....

1 Answers1

0

Try with System#getProperty() to get the below directories if you want to use absolute path under Windows system.

String userHome = System.getProperty("user.home");     
String tempDir  = System.getProperty("java.io.tmpdir"); 

Read from same package where the class is present

URL url = this.getClass().getResource("water.avi");

OR

Read from tmp folder parallel to src in your project

File file = new File("tmp/water.avi");
URL urlWaterIntake = file.toURI().toURL();
Braj
  • 46,415
  • 5
  • 60
  • 76
  • thankssss ... this "URL url = this.getClass().getResource("water.avi");" works like a heroo... –  May 13 '14 at 16:00