@Test public void testSaveProperty() { Properties props = new Properties(); props.put("two.two", "two"); props.put("one.one", "one"); props.put("_sample", "3"); String path = "src/test/resources/saved.properties"; FileUtil.saveProperty(path, props, "HEADER"); String actual = FileUtil.readFile(path); String expected = "#HEADER" + System.lineSeparator() + ".*?" + System.lineSeparator() + "_sample=3" + System.lineSeparator() + "one.one=one" + System.lineSeparator() + "two.two=two" + System.lineSeparator(); Assert.assertTrue(actual.matches(expected)); }
public static void saveProperty(String filename, Properties properties, String header) { OutputStream out = null; try { Properties sortedProperties = new SortedProperties(properties); File f = new File(filename); _log.info("Storing file to: " + f.getAbsolutePath()); out = new FileOutputStream(f); sortedProperties.store(out, header); } catch (Exception e) { _log.error(e,e); } finally { try { if(out != null) { out.close(); } } catch (IOException e) { } } }
FileUtil { public static void saveProperty(String filename, Properties properties, String header) { OutputStream out = null; try { Properties sortedProperties = new SortedProperties(properties); File f = new File(filename); _log.info("Storing file to: " + f.getAbsolutePath()); out = new FileOutputStream(f); sortedProperties.store(out, header); } catch (Exception e) { _log.error(e,e); } finally { try { if(out != null) { out.close(); } } catch (IOException e) { } } } }
FileUtil { public static void saveProperty(String filename, Properties properties, String header) { OutputStream out = null; try { Properties sortedProperties = new SortedProperties(properties); File f = new File(filename); _log.info("Storing file to: " + f.getAbsolutePath()); out = new FileOutputStream(f); sortedProperties.store(out, header); } catch (Exception e) { _log.error(e,e); } finally { try { if(out != null) { out.close(); } } catch (IOException e) { } } } private  FileUtil(); }
FileUtil { public static void saveProperty(String filename, Properties properties, String header) { OutputStream out = null; try { Properties sortedProperties = new SortedProperties(properties); File f = new File(filename); _log.info("Storing file to: " + f.getAbsolutePath()); out = new FileOutputStream(f); sortedProperties.store(out, header); } catch (Exception e) { _log.error(e,e); } finally { try { if(out != null) { out.close(); } } catch (IOException e) { } } } private  FileUtil(); static String readFile(File file); static String readFile(String filename); static byte[] readFileAsBytes(File file); static byte[] readFileAsBytes(String filename); static String backupFile(File source); static InputStream getFileStream(String name); static void writeFile(String filename, String content); static void appendFile(String filename, String content); static File createDirectory(String path); static boolean copyMultipartFile(final MultipartFile multipartFile,
			File dest); static Properties readProperty(File f); static void saveProperty(String filename, Properties properties, String header); static String getFilename(String filepath); }
FileUtil { public static void saveProperty(String filename, Properties properties, String header) { OutputStream out = null; try { Properties sortedProperties = new SortedProperties(properties); File f = new File(filename); _log.info("Storing file to: " + f.getAbsolutePath()); out = new FileOutputStream(f); sortedProperties.store(out, header); } catch (Exception e) { _log.error(e,e); } finally { try { if(out != null) { out.close(); } } catch (IOException e) { } } } private  FileUtil(); static String readFile(File file); static String readFile(String filename); static byte[] readFileAsBytes(File file); static byte[] readFileAsBytes(String filename); static String backupFile(File source); static InputStream getFileStream(String name); static void writeFile(String filename, String content); static void appendFile(String filename, String content); static File createDirectory(String path); static boolean copyMultipartFile(final MultipartFile multipartFile,
			File dest); static Properties readProperty(File f); static void saveProperty(String filename, Properties properties, String header); static String getFilename(String filepath);  }