My code is following::
Scanner sc = null; try { sc = new Scanner(new File("assets/mainmenu/readSourceFile.txt")); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block System.out.println(e1.toString()); e1.printStackTrace(); } Then, logcat show exception java.io.FileNotFoundException
How can I find my file? I tried
sc = new Scanner(new File("mainmenu/readSourceFile.txt"));
However, it's still throw FilenotFoundException
My file is in folder assets/mainmenu/readSourceFile.txt
and I've try this::
private InputStream is; try { is = this.getResources().getAssets().open("mainmenu/readSourceFile.txt"); } catch (IOException e) { e.toString(); } I use getAssets to access assets file in android. However, how can I suppose to read text file if I use InputStream
java.io.FileNotFoundException:/./asset/mainmenu/readSourceFile.txt