Topic: Applet中读取音频文件出现空指针错误

  Print this page

1.Applet中读取音频文件出现空指针错误 Copy to clipboard
Posted by: macroxmu
Posted on: 2006-04-19 12:54

代码是这样的:
public class ImageAndMusic extends Applet{
  AudioClip auc;
  public ImageAndMusic() {
    auc = getAudioClip(getCodeBase(),"hi.au");
    auc.play();
  }
  public void init()
  {
    ImageAndMusic i = new ImageAndMusic();
  }
}
但是在单步执行完“auc = getAudioClip(getCodeBase(),"hi.au");”后就会出现空指针异常:
java.lang.NullPointerException
  at java.applet.Applet.getCodeBase(Unknown Source)
  at ImageAndMusic.<init>(ImageAndMusic.java:21)
请问是为什么啊?


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923