コード例 #1
0
 public static void writeToFile(String filePath, Properties properties, String comment) {
   if (properties != null) {
     try {
       FileOutputStream fout = new FileOutputStream(new File(filePath));
       write(filePath, properties, comment, fout);
     } catch (FileNotFoundException e) {
       logger.severe(ExceptionHelper.printStackTrace(e));
     }
   } else {
     logger.info("There is no properties file written, since the properties are null! ");
   }
 }
コード例 #2
0
  public static Properties read(String filePath) {
    Properties prop = new Properties();
    FileInputStream fis;
    try {
      fis = new FileInputStream(filePath);
      prop.loadFromXML(fis);
    } catch (Exception e) {
      logger.severe(ExceptionHelper.printStackTrace(e));
    }

    return prop;
  }
コード例 #3
0
 public static void write(
     String filePath, Properties properties, String comment, OutputStream out) {
   if (properties != null) {
     if (out != null) {
       try {
         properties.storeToXML(out, comment);
       } catch (IOException e) {
         logger.severe(ExceptionHelper.printStackTrace(e));
       }
     } else {
       logger.info("There is no valid output stream, since the outputstream is null! ");
     }
   } else {
     logger.info("There is no properties file written, since the properties are null! ");
   }
 }