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 7802677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:19:45+00:00 2026-06-02T01:19:45+00:00

I am using a JOptionPane to ask the user for a file, which I

  • 0

I am using a JOptionPane to ask the user for a file, which I then give to BufferedReader. However, my code keeps throwing a FileNotFoundException. Could someone please help me to understand why.

Here is my code…

edit = JOptionPane.showInputDialog("Enter a file to edit");
try { 
    BufferedReader fIn = new BufferedReader(new FileReader(edit));
    String in;
    try {
        while((in = fIn.readLine()) != null) {
            System.out.println(in);
        }
        fIn.close();
    }
    catch (IOException ex) {
        Logger.getLogger(WordProcessor.class.getName()).log(Level.SEVERE, null, ex);
    }

    try {
        fIn.close();
    }
    catch (IOException ex) {
        Logger.getLogger(WordProcessor.class.getName()).log(Level.SEVERE, null, ex);
    }

} 
catch (FileNotFoundException ex) {
    JOptionPane.showMessageDialog(null, "File does not exist");
    }
  • 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-02T01:19:46+00:00Added an answer on June 2, 2026 at 1:19 am
    JOptionPane.showMessageDialog(null, "File does not exist");
    

    Here you should do ex.printStackTrace() it will reveal exact problem.
    Note that current directory of program will be one from where it is launched so any relative path should be in relation to that not the source directory..

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

Sidebar

Related Questions

In our Swing application, we show error messages using JOptionPane.showOptionDialog . However, some of
In Swing, I am able to prompt the user for input using JOptionPane .
I'm using BufferedReader to read a .csv file. I have no problem reading the
I’ve always been using code similar to the following to display dialogs: JOptionPane.showMessageDialog(JOptionPane.getFrameForComponent(this), …
I have a question about joptionpane. Using JOptionPane.showMessageDialog(...), we can create a message dialog.
How to hide characters using showInputDialog of JOption pane. For eg:JOptionPane.showInputDialog(Enter Your name:). I
Using LINQ on collections, what is the difference between the following lines of code?
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
I am creating an options dialog using JOptionPane.showOptionDialog(...) ; For the options parameter I
I am creating an options dialog using JOptionPane.showOptionDialog(...) When I click one of the

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.