Results 1 to 1 of 1
- 02-17-2012, 09:13 PM #1
Senior Member
- Join Date
- Aug 2009
- Posts
- 294
- Rep Power
- 0
Simple loading txt android file throws FileNotFoundException
Hi,
I want to access simple txt files that I use to load maps to my game.
I do like this:
input string = "systems\\"+name+".txt"
It prints:PHP Code:public static String[] readFile(String file) { ArrayList<String> total = new ArrayList<String>(); try { InputStream fstream = AndroidDashActivity.getThis().getAssets().open(file, AssetManager.ACCESS_STREAMING); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; while ((strLine = br.readLine()) != null) { if (!strLine.equals("")) { total.add(strLine); } } } catch (FileNotFoundException e) { System.out.println("No such file. " + file); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } String[] list = new String[total.size()]; for (int i = 0; i < list.length; i++) { list[i] = total.get(i); } return list; }
I added the folder systems to the assets folder. Then I added solar_x2.txt.No such file. systems\solar_x2.txt
java.io.FineNotFoundException_ systems\solar_x2.txt
I'v also checked the apk created and it contains assets\systems\solar_x2.txt
I'v also tried with the string "assets\\systems\\solar_x2.txt", did not work either, so what am I doing wrong?
Similar Threads
-
FileNotFoundException, FileInputStream, File
By horndinkle in forum New To JavaReplies: 3Last Post: 06-10-2011, 04:21 PM -
Simple Android Game Design
By fresh83 in forum New To JavaReplies: 1Last Post: 05-16-2011, 05:40 AM -
Simple Swing throws Exception in thread "AWT-EventQueue-0"
By sultanofswing in forum AWT / SwingReplies: 3Last Post: 10-29-2010, 09:20 PM -
Included file throws error.
By killerf2006 in forum New To JavaReplies: 3Last Post: 08-20-2010, 11:18 AM -
java.io.FileNotFoundException: (No such file or directory)
By sudukrish in forum Advanced JavaReplies: 1Last Post: 04-01-2009, 07:34 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks