Results 1 to 4 of 4
Thread: Error reading file
- 03-01-2011, 04:29 AM #1
Error reading fileJava Code:
FileInputStream fstream = new FileInputStream("C:/Users/Steve/Desktop/file.txt"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in));
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
Java Result: 1
Im 100000x sure the file is there
- 03-01-2011, 04:40 AM #2
- Join Date
- Jan 2011
- Richmond, Virginia
- Blog Entries
- Rep Power
There may be a better approach, but you could always use a filechooser.
There is definitely a better approach but I figured Id give you a suggestion.
Try creating a file object also.
File (Java 2 Platform SE v1.4.2)
You could also try
File file = new File("C:\\MyFile.txt");
- 03-01-2011, 04:40 AM #3
On the command line cd to the Desktop directory and type "dir *.txt" (without the quotes) to see if the file is there. Remember Java is case sensitive.
- 03-01-2011, 04:44 AM #4
- By jetnor in forum New To JavaReplies: 3Last Post: 02-05-2011, 03:51 AM
- By ethann_91 in forum New To JavaReplies: 1Last Post: 01-19-2010, 03:13 PM
- By sakshi in forum New To JavaReplies: 3Last Post: 07-27-2009, 08:17 AM
- By Deluyxe in forum New To JavaReplies: 8Last Post: 04-26-2009, 04:02 PM
- By Mr tuition in forum AWT / SwingReplies: 1Last Post: 01-16-2008, 12:39 AM