0

I have a audio file stored in a folder within the project and I'm trying to call the sound file within the folder.

I am able to call the file using the full URL
new java.net.URL("file:C:\NetBeansProjects\Puzzle\audio\applause2.wav"));

But is there a way to shorten it so that if I move the project I don't require changing the code?

Thanks

user3045496
  • 129
  • 1
  • 2
  • 8
  • possible duplicate of [Load a resource contained in a jar](http://stackoverflow.com/questions/574809/load-a-resource-contained-in-a-jar) – Luca Basso Ricci Feb 24 '14 at 14:53

1 Answers1

1
File file = new File("audio\applause2.wav");

Assuming you keep the audio folder at the same level relative to the jar

SimonPJ
  • 756
  • 9
  • 21
  • but at the moment the application is not jarred. I am just answering the question – SimonPJ Feb 24 '14 at 14:55
  • I partially agree: an answer can be (also) a way to give easy answer to a question, but also to prevent future questions giving a foreseen answer! The right way to do resource loading released with project is using resource loading, not local files. – Luca Basso Ricci Feb 24 '14 at 14:59