Results 1 to 9 of 9
Thread: Eclipse Issue
- 05-16-2012, 02:53 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 19
- Rep Power
- 0
Eclipse Issue
Hi all,
I am trying to get into this Eclipse application as I like the debugging in this but I have come across an odd issue.
The following code is failing with "Exception in thread "main" java.io.FileNotFoundException: objects.txt (The system cannot find the file specified)" in Eclipse
I have ensured that I have imported the txt file and can verify that the test file is present in the file system.
Also, I have copied this data over to Notepad++ along with the text file and it works exactly how I want it too,
objects.txtJava Code:import java.io.*; class Objects { public static void main(String[] args ) throws IOException { BufferedReader inFile = new BufferedReader (new FileReader ("objects.txt")); System.out.println(inFile); String inputLine; inputLine = inFile.readLine(); while (inputLine != null) { // read and show first item of line int split = inputLine.indexOf(':'); String test = inputLine.substring(0, split); System.out.println(split + " " + test); // read and show second item of line inputLine = inputLine.substring((split + 1), inputLine.length()); split = inputLine.indexOf(':'); test = inputLine.substring(0, split); System.out.println(split + " " + test); // 3rd and 4th Splits inputLine = inputLine.substring((split + 1), inputLine.length()); split = inputLine.indexOf(':'); test = inputLine.substring(0, split); System.out.println(split + " " + test); /* inputLine = inputLine.substring((split + 1), (inputLine.length() + 1)); split = inputLine.indexOf(':'); test = inputLine.substring(0, split); System.out.println(split + " " + test) */ inputLine = inFile.readLine(); } } }
Any assistance with that could help in Eclipse would be great thanks.Java Code:3:New Name:3:Y 16:Joe Bloggs:3:N 114:Another User:3:N
Last edited by GrumpyBum; 05-16-2012 at 02:54 AM. Reason: MADE ERROR BOLD
-
Re: Eclipse Issue
You need to see where Java is looking for your file, ... it isn't where you think.
Place this line of code before you try to read the file to see just where it's looking:
or even this:Java Code:System.out.println(System.getProperty("user.dir"));
Both will show you what you're doing wrong and how to fix it.Java Code:File file = new File("objects.txt"); System.out.println(file.getAbsolutePath()); BufferedReader inFile = new BufferedReader (new FileReader(file));
- 05-16-2012, 03:06 AM #3
Member
- Join Date
- Apr 2012
- Posts
- 19
- Rep Power
- 0
Re: Eclipse Issue
Instant Fix, Thank you so much. This has allowed me to see more and resolve quickly.
- 05-16-2012, 06:15 AM #4
Re: Eclipse Issue
Forum Rules
Especially the third paragraph.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 05-16-2012, 06:23 AM #5
Member
- Join Date
- Apr 2012
- Posts
- 19
- Rep Power
- 0
Re: Eclipse Issue
Sorry Darryl, I am at a loss here. All I can think of is does this have an inappropriate title?
I have just read over the rules again but I am unsure what you are pointing out here.
If you can provide a little more information then I will know for next time.
- 05-16-2012, 06:42 AM #6
Re: Eclipse Issue
So you think "Eclipse Issue" is a good title for this thread?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 05-16-2012, 06:45 AM #7
Member
- Join Date
- Apr 2012
- Posts
- 19
- Rep Power
- 0
Re: Eclipse Issue
The purpose of the post was due to the fact that the code works else where, just not in Eclipse.
Hence the question was primarily around the way Eclipse accessed data.
This title was chosen as I the issue was based on Eclipse.
The only other thing I can think of at the moment is "Eclipse data access issue"
- 05-16-2012, 06:55 AM #8
Re: Eclipse Issue
That's certainly better, except that 'data' rather implies database access.
I think I would have gone with "FileNotFoundException in Eclipse"
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 05-16-2012, 06:58 AM #9
Member
- Join Date
- Apr 2012
- Posts
- 19
- Rep Power
- 0
Similar Threads
-
issue with eclipse startup
By reenu chaudhary in forum EclipseReplies: 0Last Post: 04-04-2012, 08:57 AM -
Eclipse Window BUilder issue!
By christopherx in forum EclipseReplies: 1Last Post: 02-04-2012, 05:05 AM -
Eclipse and Tomcat 6+7 issue
By Sno in forum EclipseReplies: 0Last Post: 01-22-2011, 08:11 PM -
Eclipse load issue with Fedora Core 9
By digilogik in forum EclipseReplies: 2Last Post: 11-01-2008, 05:22 AM -
Tapestry, Eclipse- Tomcat/Weblogic <jwcid> issue - Please help
By apmaddali in forum Web FrameworksReplies: 0Last Post: 04-21-2008, 06:21 AM


3Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks