Solved

Can't open file

Posted on 2006-07-15
4
206 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android studio getdrawable(int) is deprecated 4 120
Opening PDF on button click and fill new document 2 47
printf performancy 11 70
Bot application - advice 3 38
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to implement Singleton Design Pattern in Java.
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.

839 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