public static String readFileAsString(String filePath) { byte[] buffer = new byte[(int) getFile(filePath).length()]; BufferedInputStream inputStream = null; try { inputStream = new BufferedInputStream(new FileInputStream(getFile(filePath))); inputStream.read(buffer); } catch(Exception e) { throw LOG.exceptionWhileReadingFile(filePath, e); } finally { IoUtil.closeSilently(inputStream); } return new String(buffer, Charset.forName("UTF-8")); }
public static String readFileAsString(String filePath) { byte[] buffer = new byte[(int) getFile(filePath).length()]; BufferedInputStream inputStream = null; try { inputStream = new BufferedInputStream(new FileInputStream(getFile(filePath))); inputStream.read(buffer); } catch(Exception e) { throw LOG.exceptionWhileReadingFile(filePath, e); } finally { IoUtil.closeSilently(inputStream); } return new String(buffer, Charset.forName("UTF-8")); }
public static void writeStringToFile(String content, String filePath) { BufferedOutputStream outputStream = null; try { outputStream = new BufferedOutputStream(new FileOutputStream(getFile(filePath))); outputStream.write(content.getBytes()); outputStream.flush(); } catch(Exception e) { throw LOG.exceptionWhileWritingToFile(filePath, e); } finally { IoUtil.closeSilently(outputStream); } }
public static void writeStringToFile(String content, String filePath) { BufferedOutputStream outputStream = null; try { outputStream = new BufferedOutputStream(new FileOutputStream(getFile(filePath))); outputStream.write(content.getBytes()); outputStream.flush(); } catch(Exception e) { throw LOG.exceptionWhileWritingToFile(filePath, e); } finally { IoUtil.closeSilently(outputStream); } }
@Override protected void starting(Description description) { if(perfTestConfiguration == null) { File file = IoUtil.getFile(PROPERTY_FILE_NAME); if(!file.exists()) { throw new PerfTestException("Cannot load file '"+PROPERTY_FILE_NAME+"': file does not exist."); } FileInputStream propertyInputStream = null; try { propertyInputStream = new FileInputStream(file); Properties properties = new Properties(); properties.load(propertyInputStream); perfTestConfiguration = new PerfTestConfiguration(properties); } catch(Exception e) { throw new PerfTestException("Cannot load properties from file "+PROPERTY_FILE_NAME+": "+e); } finally { IoUtil.closeSilently(propertyInputStream); } } }
public static String readFileAsString(String filePath) { byte[] buffer = new byte[(int) getFile(filePath).length()]; BufferedInputStream inputStream = null; try { inputStream = new BufferedInputStream(new FileInputStream(getFile(filePath))); inputStream.read(buffer); } catch(Exception e) { throw LOG.exceptionWhileReadingFile(filePath, e); } finally { IoUtil.closeSilently(inputStream); } return new String(buffer, Charset.forName("UTF-8")); }
public static void writeStringToFile(String content, String filePath) { BufferedOutputStream outputStream = null; try { outputStream = new BufferedOutputStream(new FileOutputStream(getFile(filePath))); outputStream.write(content.getBytes()); outputStream.flush(); } catch(Exception e) { throw LOG.exceptionWhileWritingToFile(filePath, e); } finally { IoUtil.closeSilently(outputStream); } }