Properties

M

Marcin Go³dyn

Hi
I have a properties file access.properties and i try to add something to
this empty file. I use this code :
Properties properties = new Properties();
try {
properties.load(new FileInputStream("access.properties"));
} catch (IOException e) {
System.out.println(e.getMessage());
}

properties.setProperty("/db","1");

try {
properties.store(new FileOutputStream("access.properties"), null);
} catch (IOException e) {
System.out.println(e.getMessage());
}

but it isnt work file is still empty 0 exceptions why??
Marcin Goldyn
 
D

david bydefault

but it isnt work file is still empty 0 exceptions why??
Marcin Goldyn
Are you using a IDE? If you are compiling and running from the console,
it should work. Otherwise, maybe you are not looking at the folder where
the IDE runs the code.
 
W

Wendy Smoak

Marcin Go³dyn said:
I have a properties file access.properties and i try to add something to
this empty file. I use this code :

but it isnt work file is still empty 0 exceptions why??

Your code worked fine for me. Where is your access.properties file located?
Are you sure you have write permission down to the directory and on the file
itself?
 
M

Marcin Go³dyn

Hi
I`m stupid. Of course file is stored in my main IDE catalog.
forgive me this post. Thx for your advices and attention.
Marcin Goldyn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top