Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 109337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:03:13+00:00 2026-05-11T02:03:13+00:00

So my 2009 new years resolution is to learn Java. I recently acquired Java

  • 0

So my 2009 new years resolution is to learn Java. I recently acquired ‘Java for Dummies’ and have been following along with the demo code in the book by re-writing it using Eclipse. Anyway, every example in the book that uses a relative path does not seem to read the .txt file it’s supposed to read from.

Here is the sample code:

import java.util.Scanner; import java.io.File; import java.io.IOException; import javax.swing.JFrame; import javax.swing.JLabel; import java.awt.GridLayout;  class TeamFrame extends JFrame {      public TeamFrame() throws IOException {         PlayerPlus player;         Scanner myScanner = new Scanner(new File('Hankees.txt'));          for (int num = 1; num <= 9; num++) {             player = new PlayerPlus(myScanner.nextLine(), myScanner.nextDouble());             myScanner.nextLine();             addPlayerInfo(player);         }                add(new JLabel());         add(new JLabel('   ------'));         add(new JLabel('Team Batting Aberage:'));         add(new JLabel(PlayerPlus.findTeamAverageString()));         setTitle('The Hankees');         setLayout(new GridLayout(11,2));         setDefaultCloseOperation(EXIT_ON_CLOSE);         pack();         setVisible(true);     }      void addPlayerInfo(PlayerPlus player) {         add(new JLabel(player.getName()));         add(new JLabel(player.getAverageString()));     } } 

And you can see in the below screen shot I have included this file.

image no longer available

Also, I have verified that when I build the application that a copy of Hankees.txt is placed in the bin folder with the compiled .class files.

Lastly, if I change line 12 to the following and place Hankees.txt in the root of my C:\ drive the program compiles and runs fine.

Scanner myScanner = new Scanner(new File('C:\\Hankees.txt')); 

So basically, my question is what am I doing wrong? Or is Eclipse responsible for this in some way?

Thanks for any and all help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:03:13+00:00Added an answer on May 11, 2026 at 2:03 am

    You need 'src/Hankees.txt'

    Your file is in the source folder which is not counted as the working directory.\

    Or you can move the file up to the root directory of your project and just use 'Hankees.txt'

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 67k
  • Answers 67k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I expect here the problem is your getComments() function (for… May 11, 2026 at 11:49 am
  • added an answer I feel your pain with some of the organization issues… May 11, 2026 at 11:49 am
  • added an answer The (old) Windows binaries page at tigris.org contains an installer… May 11, 2026 at 11:49 am

Related Questions

So my 2009 new years resolution is to learn Java. I recently acquired Java
So my company stores alot of data in a foxpro database and trying to
So my company uses a delightfully buggy program called Rational Purify (as a plugin
So my favourite web tool, Subtlety , was recently discontinued, which means that I
So my list looks something like this: <div=list> <ul> <li class=page item>Parent 1 <ul>
So my code is below. I'm not getting any errors and it places everything
So my Vista machine is set to turn off it's monitors after 10 minutes.
So my goal here is to have a single search field in an application
So my question is if I can somehow send data to my program and
ok so my issue is i have the string '\222\222\223\225' which is stored as

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.