I am trying to access the audio file from the jar,for doing that i wrote a code,like
...
try {
InputStream is =
getClass().getResourceAsStream("audio.wav");
Player player = Manager.createPlayer(is, "audio/X-wav");
p.start();
}
catch(IOException ioe) {
}
catch(MediaException me) {
}
...
but here in this snippet,what is the use of getClass()?
It allows you to get the class of the current object, so in turn you can access resources.
getResourceAsStreamloads resources from the class loader associated with the class. See the documentation forObject.getClassandClass.getResourceAsStream.