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) {
Logger.getLogger(PropertyFactory.class.getName()).log(Level.SEVERE, null, ex);
}
try {
p.store(pw, comment);
} catch (IOException ex) {
Logger.getLogger(PropertyFactory.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static Properties read(String fileName) {
Properties p = new Properties();
Reader r = null;
try {
r = new FileReader(fileName);
} catch (FileNotFoundException ex) {
Logger.getLogger(PropertyFactory.class.getName()).log(Level.SEVERE, null, ex);
}
try {
p.load(r);
} catch (IOException ex) {
Logger.getLogger(PropertyFactory.class.getName()).log(Level.SEVERE, null, ex);
}
return p;
}
}
Log teknis programmer Java
Selasa, 05 Mei 2009
Properties Factory buat nyimpen setingan file
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar