您的位置:首页 > 其它

设置RAC的归档模式

2010-07-30 14:55 471 查看
/**
 * properties文件的读写操作
 * @author dKF24478
 *
 */
public class PropertiesHelp {
 private Properties p ;
 private FileInputStream inputFile;  
    private FileOutputStream outputFile;
    private static Map<String, String> configMap = new HashMap<String, String>();
 private String filePath;
 
 public PropertiesHelp(String filePath) {
  try {
   this.filePath = filePath;
   p = new Properties();
   inputFile = new FileInputStream(filePath);
   p.load(inputFile);
      inputFile.close();  
  } catch (Exception e) {
   e.printStackTrace();
  }
 }
 
 public void readProperties() throws Exception {
  String dbbase1 = p.getProperty("dbbase1");
  String dbproject1 = p.getProperty("dbproject1");
  String dbbase2 = p.getProperty("dbbase2");
  String dbproject2 = p.getProperty("dbproject2");
  String compareTool = p.getProperty("compareTool");
  
  if(null == dbbase1 || "".equals(dbbase1)){
   return ;
  }
  if(null == dbproject1 || "".equals(dbproject1)){
   return ;
  }
  if(null == dbbase2 || "".equals(dbbase2)){
   return ;
  }
  if(null == dbproject2 || "".equals(dbproject2)){
   return ;
  }
  
  
  configMap.put("dbbase1", dbbase1);
  configMap.put("dbproject1", dbproject1);
  configMap.put("dbbase2", dbbase2);
  configMap.put("dbproject2", dbproject2);
  configMap.put("compareTool", compareTool);
  
 }
 
 
 public void writeProperties(Map<String, String> configMap) throws Exception {
  Set<Entry<String,String>> set = configMap.entrySet();
  for (Entry<String, String> entry : set) {
   p.setProperty(entry.getKey(), entry.getValue());
  }
  
  
  outputFile = new FileOutputStream(filePath);  
  p.store(outputFile, "configInfo");
  outputFile.close();  
 }
 
 public static Map<String, String> getConfigMap() {
  return configMap;
 }
 
 public static void main(String[] args) throws Exception{
  PropertiesHelp ph = new PropertiesHelp("config.properties");
  //ph.writeProperties();
  ph.readProperties();
 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: