Solved

Can't open file

Posted on 2006-07-15
4
202 Views
Last Modified: 2010-05-18
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.
0
Comment
Question by:matthew016
  • 2
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 400 total points
ID: 17114600
Try


BufferedReader in = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("database")));
0
 
LVL 24

Assisted Solution

by:sciuriware
sciuriware earned 100 total points
ID: 17114601
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
 
LVL 24

Expert Comment

by:sciuriware
ID: 17114604
And then I wanted to add what CEHJ said.

;JOOP!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17114817
:-)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now