K
Krick
Is it ok for me to have a FileInputStream and a FileOutputStream open
on the same file at the same time? Should I be closing and reopening
the file or is something happening behind the scenes that I'm not
aware of? Here's my sample code which seems to work ok:
String property;
File f = new File("my.properties");
Properties p = new Properties();
// load the properties from the file
try {
p.load(new FileInputStream(f));
}
catch (IOException ex) {
}
// get the property
property = p.getProperty("foo");
// do stuff here, possibly modifying property
// set the property
p.setProperty("foo", property);
// store the properties to the file
try {
p.store(new FileOutputStream(f), "MY PROPERTIES");
}
catch (IOException ex) {
}
....
Krick
on the same file at the same time? Should I be closing and reopening
the file or is something happening behind the scenes that I'm not
aware of? Here's my sample code which seems to work ok:
String property;
File f = new File("my.properties");
Properties p = new Properties();
// load the properties from the file
try {
p.load(new FileInputStream(f));
}
catch (IOException ex) {
}
// get the property
property = p.getProperty("foo");
// do stuff here, possibly modifying property
// set the property
p.setProperty("foo", property);
// store the properties to the file
try {
p.store(new FileOutputStream(f), "MY PROPERTIES");
}
catch (IOException ex) {
}
....
Krick