Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Can't open file

Posted on 2006-07-15
4
Medium Priority
?
211 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 1600 total points
ID: 17114600
Try


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

Assisted Solution

by:sciuriware
sciuriware earned 400 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

886 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