Java Applet无法找到文件

时间:2012-12-08 01:12:58

标签: java file applet

  

可能重复:
  Applet not reading file

我有一个applet,我正在尝试读取文件。它抛出一个filenotfound异常,但我传递了正确的路径,所以我不知道我哪里出错了。我正在使用它来读取数字并使用这些数字来更改多维数组,如果你想知道的话。下面是代码:

public class Save {
    public void loadSave(File loadPath) {
        try {
            Scanner loadScanner = new Scanner(loadPath);

            while(loadScanner.hasNext()){
                for(int y = 0; y < Screen.room.block.length;y++){
                    for(int x = 0; x < Screen.room.block[0].length;x++){
                        Screen.room.block[y][x].groundID = loadScanner.nextInt();
                        System.out.println(loadScanner.nextInt());
                    }   
                }
                for(int y = 0; y < Screen.room.block.length;y++){
                    for(int x = 0; x < Screen.room.block[0].length;x++){
                        Screen.room.block[y][x].airID = loadScanner.nextInt();
                    }   
                }
            }
            loadScanner.close();
        } catch (Exception e) { e.printStackTrace();}
    }
}

我如何访问它:

save.loadSave(new File(frame.getClass().getResource("mission1.tdm").toString()));

0 个答案:

没有答案