我在我的 getCodeBase 方法中将音频文件 url 放入我的应用程序时遇到问题:
public class Audioapp extends JApplet
{
public class Sound // Holds one audio file
{
private AudioClip song; // Sound player
private URL songPath; // Sound path
Sound(String filename)
{
try
{
songPath = new URL(getCodeBase("G:\\Uni\\Programming\\Rolling assignements\\Week0\\Programming week21"),filename); // This is the place were im getting error
song = Applet.newAudioClip(songPath); // Load the Sound
}
catch(Exception e){e.printStackTrace();}
}
public void playSound()
{
song.play(); // Play
}
}
}
我得到的错误是:
The method getCodeBase() in the type Applet is not applicable for the arguments (String)
我在网上按照教程进行了操作,并且正确且完整地遵循了它。但是缺少/错误的是什么?