-1
이것은 게임 프로젝트입니다. 프로젝트를 소개하고 가상 머신에서 실행 한 후에는 검은 색 프레임이었습니다. 게임 화면이 없습니다.안드로이드 프로젝트를 소개 할 때의 FileIO 예외
package com.badlogic.androidgames.jumper;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import com.badlogic.androidgames.framework.FileIO;
public class Settings {
public static boolean soundEnabled = true;
public final static int[] highscores = new int[] { 100, 80, 50, 30, 10 };
public final static String file = ".superjumper";
public static void load(FileIO files) {
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(files.readFile(file))); // 这里报异常
soundEnabled = Boolean.parseBoolean(in.readLine());
for(int i = 0; i < 5; i++) {
highscores[i] = Integer.parseInt(in.readLine());
}
} catch (IOException e) {
// :(It's ok we have defaults
} catch (NumberFormatException e) {
// :/ It's ok, defaults save our day
} finally {
try {
if (in != null)
in.close();
} catch (IOException e) {
}
}
}
public static void save(FileIO files) {
BufferedWriter out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(
files.writeFile(file)));
out.write(Boolean.toString(soundEnabled));
out.write("\n");
for(int i = 0; i < 5; i++) {
out.write(Integer.toString(highscores[i]));
out.write("\n");
}
} catch (IOException e) {
} finally {
try {
if (out != null)
out.close();
} catch (IOException e) {
}
}
}
public static void addScore(int score) {
for(int i=0; i < 5; i++) {
if(highscores[i] < score) {
for(int j= 4; j > i; j--)
highscores[j] = highscores[j-1];
highscores[i] = score;
break;
}
}
}
}
I 중단 점과 디버그 오류는 FileNotFoundException
입니다. mmnt/SdCard
에 superjumper
을 찾을 수 없습니다.
코드에 대한 문제는 없습니다. 왜 예외가 있습니까?