Property Factory to save configuration in file config

| Sunday, December 27, 2009

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

public class PropertyFactory {

public static void save(Properties p, String fileName, String comment) {
PrintWriter pw = null;
try {
pw = new PrintWriter(fileName);
} catch (FileNotFoundException ex) {

}
try {
p.store(pw, comment);
} catch (IOException ex) {

}
}

public static Properties read(String fileName) {
Properties p = new Properties();
Reader r = null;
try {
r = new FileReader(fileName);
} catch (FileNotFoundException ex) {

}
try {
p.load(r);
} catch (IOException ex) {

}
return p;
}
}

0 comments:

Post a Comment