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

  • SEARCH
  • Home
  • 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 8061825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:28:23+00:00 2026-06-05T10:28:23+00:00

I have this program that needs to read diffrent files for diffrent selected items

  • 0

I have this program that needs to read diffrent files for diffrent selected items in a JComboBox. I have gotten the JComboBox and everything to work but now when i try to call the Course_loader code it wont run. Here is the code of where i try to call it from:

    public static String CourseName;
public static String PlayerName;
public Start_round(){
    try {
        Course_loader cl = new Course_loader();
        cl.loadCourse(CourseName);
    } catch (IOException e) {
    }

And now here is the code of the file reader:

    import java.io.*;
    public class Course_loader {
public static String holes;
public void loadCourse(String s) throws IOException{
    File f = new File("courses\\"+s+".txt");
    BufferedReader reader = new BufferedReader(new FileReader(f));
    holes = reader.readLine();
    reader.close();
    System.out.println("it ran");
}

}

When ever i call the code it dosnt print out the “it ran”. I have checked over my code my self but i am new to the File reader stuff. Please help. Thanks in advance.

oh and the file is there and it has these words in it

    test

and when ever it try to print the string it is null which proves that the stuff isnt running.

  • 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. Editorial Team
    Editorial Team
    2026-06-05T10:28:25+00:00Added an answer on June 5, 2026 at 10:28 am

    You’re silently ignoring IOException.

    Change the exception handling in Start_round to this:

    try
    {
        // your "load course" code ...
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    

    This should generate some output that will give you an idea of what’s going wrong with the FileReader code, for example, File not found issues.

    Another tip: Always put your reader.close() call in a finally block. In your case this means doing some specific exception handling in your loadCourse method. Search around for java filereader, and similar searches to look for best practices. Also, do some work learning about Exceptions, try/catch/finally if you don’t understand that stuff very well.

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

Sidebar

Related Questions

I have a program that needs to read data from a number of sources.
I have a program that looks like this. I need to consistently write something
I have this program that should execute a piece of code base on the
I have this program that I am working on for class, I think the
I have a C/ncurses program that I'm debugging/maintaining. This program does ripoffline twice: first,
I have made a program that scans rss feeds. This same program creates feeds
I have a program that looks something like this: public partial class It {
I have a program that simulates mouse click. Code is something like this: [DllImport(user32.dll,
I have a program that generates a .shp file, and exports this as a
I have written a program that uses qhttp to get a webpage. This works

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.