I cant understand what the error of this code.
public void run(String url) {
try {
FileInputStream file;
file = new FileInputStream(this.getClass().getResource(url));
Player p = new Player(file);
p.play();
}catch(Exception e){
System.err.print( url + e);
}
}
when i try to run it, it says me “no suitable constructor found for FileInputStream(URL)”. Why its happening?
Put the file in root of folder of your class path (folder where your
.classfiles are generated) and then use statements below:Here
filePathis the relative file path w.r.t. the root folder.