Hello i got a quite annoying problem i'd like to read text files similar to this
KEY
0 1 2 3 4 5 6 7
KEYEND
i tried to use scanner class, because it can return results as strings, decimals, whatever
public static void LoadStuff(String Name) {
Scanner reader = null;
try {
reader = new Scanner(new File(Name));
} catch (Exception e) {
Log.d("damn", "FAIL");
}
if(reader != null)
Load(reader);
}
private static void Load(Scanner reader) {
while (reader.hasNext()) {
String result = reader.next();
if (result == "KEY") { // may be result.equalsignorecase
while (result != "KEYEND") {
int index = reader.nextInt();
Log.d("Index", String.valueOf(index));
}
}
}
reader.close();
}
i cant do above, cause scanner cant find the file, parsing like "file.txt" doesnt work, tried also with path like this "res/data/file.txt" also doesnt work where should i put the file and how to get the directory to make it work thanks