Results 1 to 6 of 6
Thread: reading file from a path
- 08-16-2009, 10:32 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 17
- Rep Power
- 0
-
How are you trying to read it, and we can tell you perhaps where you're going wrong. Also, if you get an error (ever) and need to ask a question about it here, please post the error message completely and indicate in your code where the error is occurring, usually by placing a comment like so:
[/code]Java Code:for (int i = 0; i <= myArray.length; i++) { System.out.println(myArray[i]); // **** array index out of bounds occurs here **** }
- 08-16-2009, 11:24 PM #3
Member
- Join Date
- Aug 2009
- Posts
- 17
- Rep Power
- 0
instead of the file there...i want to read it from the path given aboveJava Code:BufferedReader br = new BufferedReader(new FileReader("tw106.txt")); while((br.readLine()) != null) { for(int i=0; i<178690; i++) { wordList[i] = br.readLine(); } }
- 08-17-2009, 01:54 AM #4
You need to create a file object:
Java Code:BufferedReader br = new BufferedReader(new FileReader(new File("tw106.txt")));
-
I don't think that the problem is the one outlined by quad above as FileReader has a constructor that takes String and likely creates a File within the constructor. The problem is likely that the file is not located where he's looking. To the original poster, run this in your program:
This will tell you where the JVM is looking for your file.Java Code:System.out.println(System.getProperties("user.dir"));
- 08-17-2009, 04:52 AM #6
Similar Threads
-
find file with * on the path
By itaipee in forum New To JavaReplies: 7Last Post: 07-08-2009, 08:05 AM -
Weird path problem when reading properties file
By jerry_popperq in forum New To JavaReplies: 0Last Post: 03-18-2009, 03:32 PM -
How to set Image file path
By anil.bharadia in forum AWT / SwingReplies: 1Last Post: 01-28-2009, 09:10 PM -
Platform dependent File Path....
By sanjayksaini in forum Advanced JavaReplies: 7Last Post: 11-30-2008, 03:12 AM -
file path
By Arsench in forum New To JavaReplies: 7Last Post: 10-30-2008, 05:39 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks