Okai so I have a jfilechooser
:

JFileChooser chooser = new JFileChooser();
int returnName = chooser.showOpenDialog(null);

            if (returnName == JFileChooser.APPROVE_OPTION) {
                 f = chooser.getSelectedFile();
                if (f != null) { // Make sure the user didn't choose a directory.

                    path = f.getAbsolutePath();//get the absolute path to selected file
                    //below line to test the file chooser
                    //System.out.println(path);
                }

                System.out.println (path);

so now the path is c:\fa\sdf\asdf\sfd\sadf\fsaf.txt

But I want this path to go into this:

BufferedReader in = new BufferedReader(
new FileReader(
"path"));

But its not working ?????

Recommended Answers

All 3 Replies

NVM.... I forgot to take of the "".. lol

Hi, infact the path name should not contain back slash but forward slash, what i mean is / instead of \

try replace c:\fa\sdf\asdf\sfd\sadf\fsaf.txt
with c:/fa/sdf/asdf/sfd/sadf/fsaf.txt

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.