Hello ,

This is my first post in this forum.
I am a newbie to IntelliJ  IDEA.On writing a simple program of file handling,it's showing a ''
although the file is there.

s = new Scanner(new BufferedReader(new FileReader("/media/arg/Data/Movies.txt")));

Screenshot from 2013-09-26 12:55:31.png

I would appreciate if you can help.Thank you.

Comment actions Permalink

Your screenshot did not post correctly. So I'm not 100% sure this is what is happening. But I believe it is... Is the error "Unhandled exception:"  showing in the IDEA editor window? If so, that is because the FileReader constructor throws a FileNotFoundException which is a caught exception. (The file may be there now when coding, but it doesn't mean it'll be there on the system where the code is run.) So you either need to wrap that code in a try/catch block, or have the containing exception rethrow the exception. Put your cursor over the underlined error and open the Quick Fix pop-up [Alt + Enter (Windows) or   (Mac)]. From the Quick Fix pop-up you can select one of those options and IDEA will auto generate the code.

If that's not the error you are getting, can you repost your screenshot.

Comment actions Permalink

Another case is that you get this error on running java application.

If you get the same error on running this application outside IDEA, from command line, then the problem is in your code.
If the application successfully runs from command line, check main menu / Run / Edit Configurations, your configuration, Working directory field.



Please sign in to leave a comment.