Results 1 to 4 of 4
Thread: Error reading file
- 03-01-2011, 04:29 AM #1
Error reading file
I keep getting Error: C:\Users\Steve\Desktop\file.txt (The system cannot find the file specified)Java 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
at matrixapplication.Matrix.getValAt(Matrix.java:36)
at matrixapplication.Main.main(Main.java:20)
Java Result: 1
Im 100000x sure the file is there
- 03-01-2011, 04:40 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
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
Give all those a shot and see if any of them workJava Code: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
Similar Threads
-
Reading A CSV file error.
By jetnor in forum New To JavaReplies: 3Last Post: 02-05-2011, 03:51 AM -
Error on reading text from a file.
By ethann_91 in forum New To JavaReplies: 1Last Post: 01-19-2010, 03:13 PM -
error in reading objects from file
By sakshi in forum New To JavaReplies: 3Last Post: 07-27-2009, 08:17 AM -
Error Message when reading an input file.
By Deluyxe in forum New To JavaReplies: 8Last Post: 04-26-2009, 04:02 PM -
reading from a zip file, error
By Mr tuition in forum AWT / SwingReplies: 1Last Post: 01-16-2008, 12:39 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks