public static Writer getWriter(File file, String encoding) throws IllegalStateException { return getWriter(file, encoding, false); }
public static Writer getWriter(OutputStream outputStream, String encoding) throws IllegalStateException { return getWriter(outputStream, encoding, false); }
public static Writer getWriter(File file, String encoding, boolean append) throws IllegalStateException { boolean insertBom = !append; return getWriter(file, encoding, append, insertBom); }
public static Writer getWriter(File file) throws IllegalStateException { return getWriter(file, DEFAULT_ENCODING); }
public static Writer getWriter(File file, String encoding, boolean append) throws IllegalStateException { boolean insertBom = !append; return getWriter(file, encoding, append, insertBom); }
public static Writer getWriter(File file, String encoding) throws IllegalStateException { return getWriter(file, encoding, false); }
public static Writer getWriter(File file) throws IllegalStateException { return getWriter(file, DEFAULT_ENCODING); }
public static Writer getWriter(OutputStream outputStream, String encoding) throws IllegalStateException { return getWriter(outputStream, encoding, false); }
public static BufferedWriter getBufferedWriter(File file, String encoding) throws IllegalStateException { Writer writer = getWriter(file, encoding); return new BufferedWriter(writer); }
public static BufferedWriter getBufferedWriter(File file, String encoding) throws IllegalStateException { Writer writer = getWriter(file, encoding); return new BufferedWriter(writer); }
@Override protected Writer createWriter(final Resource file) { return FileHelper.getWriter(file.write(), FileHelper.DEFAULT_ENCODING); } };
public static void writeString(OutputStream outputStream, String string, String encoding) throws IllegalStateException { final Writer writer = getWriter(outputStream, encoding); writeString(writer, string, encoding); }
@Override protected Writer createWriter(final Resource resource) { final OutputStream outputStream = resource.write(); return FileHelper.getWriter(outputStream, getSafeEncoding()); } };
public static Writer getWriter(File file, String encoding, boolean append, boolean insertBom) throws IllegalStateException { if (append && insertBom) { throw new IllegalArgumentException("Can not insert BOM into appending writer"); } final OutputStream outputStream = getOutputStream(file, append); return getWriter(outputStream, encoding, insertBom); }
public static Writer getWriter(File file, String encoding, boolean append, boolean insertBom) throws IllegalStateException { if (append && insertBom) { throw new IllegalArgumentException("Can not insert BOM into appending writer"); } final OutputStream outputStream = getOutputStream(file, append); return getWriter(outputStream, encoding, insertBom); }
public static void writeString(OutputStream outputStream, String string, String encoding) throws IllegalStateException { final Writer writer = getWriter(outputStream, encoding); writeString(writer, string, encoding); }
public void generateCoreFile() throws IOException { final File coreSiteFile = new File(confFolder, "conf-site.xml"); try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("core-site-template.xml")) { final BufferedReader reader = FileHelper.getBufferedReader(inputStream, FileHelper.UTF_8_ENCODING); try (Writer writer = FileHelper.getWriter(coreSiteFile)) { String line = reader.readLine(); while (line != null) { line = line.replace("${PATH}", path); writer.write(line); line = reader.readLine(); } writer.flush(); } } }
private void createTemporaryHadoopConfFile(final File hadoopConfDir, final String filename, final String templateName) throws IOException { final File coreSiteFile = new File(hadoopConfDir, filename); try (InputStream inputStream = getClass().getResourceAsStream(templateName)) { final BufferedReader reader = FileHelper.getBufferedReader(inputStream, FileHelper.UTF_8_ENCODING); try (Writer writer = FileHelper.getWriter(coreSiteFile)) { String line = reader.readLine(); while (line != null) { line = StringUtils.replaceAll(line, "${HDFS_HOSTNAME}", _defaultFs.getHost()); line = StringUtils.replaceAll(line, "${HDFS_PORT}", _defaultFs.getPort() + ""); writer.write(line); line = reader.readLine(); } writer.flush(); } } }
private Writer getWriter(boolean append) { if (_writer == null || !append) { final boolean needsLineBreak = needsLineBreak(_resource, _configuration); final OutputStream out; if (append) { out = _resource.append(); } else { out = _resource.write(); } final boolean insertBom = !append; final Writer writer = FileHelper.getWriter(out, _configuration.getEncoding(), insertBom); if (needsLineBreak) { try { writer.write('\n'); } catch (IOException e) { logger.debug("Failed to insert newline", e); } } _writer = writer; } return _writer; }
private Writer getWriter(boolean append) { if (_writer == null || !append) { final boolean needsLineBreak = needsLineBreak(_resource, _configuration); final OutputStream out; if (append) { out = _resource.append(); } else { out = _resource.write(); } final boolean insertBom = !append; final Writer writer = FileHelper.getWriter(out, _configuration.getEncoding(), insertBom); if (needsLineBreak) { try { writer.write('\n'); } catch (IOException e) { logger.debug("Failed to insert newline", e); } } _writer = writer; } return _writer; }