Results 1 to 9 of 9
Like Tree3Likes
  • 1 Post By Fubarable
  • 2 Post By GrumpyBum

Thread: Eclipse Issue

  1. #1
    GrumpyBum is offline Member
    Join Date
    Apr 2012
    Posts
    19
    Rep Power
    0

    Unhappy 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,

    Java 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();
    		}	
    	}
    }
    objects.txt
    Java Code:
    3:New Name:3:Y
    16:Joe Bloggs:3:N
    114:Another User:3:N
    Any assistance with that could help in Eclipse would be great thanks.

    Eclipse Issue-screenshot008.jpg
    Last edited by GrumpyBum; 05-16-2012 at 02:54 AM. Reason: MADE ERROR BOLD

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default 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:

    Java Code:
    System.out.println(System.getProperty("user.dir"));
    or even this:
    Java Code:
          File file = new File("objects.txt");
          System.out.println(file.getAbsolutePath());
          
          BufferedReader inFile = new BufferedReader (new FileReader(file));
    Both will show you what you're doing wrong and how to fix it.
    GrumpyBum likes this.

  3. #3
    GrumpyBum is offline Member
    Join Date
    Apr 2012
    Posts
    19
    Rep Power
    0

    Default Re: Eclipse Issue

    Instant Fix, Thank you so much. This has allowed me to see more and resolve quickly.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

    Default Re: Eclipse Issue

    Forum Rules
    Especially the third paragraph.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    GrumpyBum is offline Member
    Join Date
    Apr 2012
    Posts
    19
    Rep Power
    0

    Default 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.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

    Default Re: Eclipse Issue

    So you think "Eclipse Issue" is a good title for this thread?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    GrumpyBum is offline Member
    Join Date
    Apr 2012
    Posts
    19
    Rep Power
    0

    Default 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"

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

    Default Re: Eclipse Issue

    That's certainly better, except that 'data' rather implies database access.
    I think I would have gone with "FileNotFoundException in Eclipse"

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  9. #9
    GrumpyBum is offline Member
    Join Date
    Apr 2012
    Posts
    19
    Rep Power
    0

    Default Re: Eclipse Issue

    Quote Originally Posted by DarrylBurke View Post
    "FileNotFoundException in Eclipse"
    That would be a good title, I will put some more thought into this next time.

    Thanks,
    DarrylBurke and Fubarable like this.

Similar Threads

  1. issue with eclipse startup
    By reenu chaudhary in forum Eclipse
    Replies: 0
    Last Post: 04-04-2012, 08:57 AM
  2. Eclipse Window BUilder issue!
    By christopherx in forum Eclipse
    Replies: 1
    Last Post: 02-04-2012, 05:05 AM
  3. Eclipse and Tomcat 6+7 issue
    By Sno in forum Eclipse
    Replies: 0
    Last Post: 01-22-2011, 08:11 PM
  4. Eclipse load issue with Fedora Core 9
    By digilogik in forum Eclipse
    Replies: 2
    Last Post: 11-01-2008, 05:22 AM
  5. Replies: 0
    Last Post: 04-21-2008, 06:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •