Can't open file

I have a file called "database" where I have the url, login and pass to have an access to my DB.

I'm using this to open it :

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

But it just won't work.
The class where this line appear is in a package.
I have put the file out of the packages and in the package, but nothing work.

I'm using J2EE and Webtools Platform.
LVL 9
matthew016Asked:
Who is Participating?
 
CEHJCommented:
Try


BufferedReader in = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("database")));
0
 
sciuriwareCommented:
You did not give the right directory/folder.
Where is your program running and where is that file?

Proove this by applying the full path name; then it works.

;JOOP!
0
 
sciuriwareCommented:
And then I wanted to add what CEHJ said.

;JOOP!
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.