List of utility methods to do Text File Write by Charset
void | copy(byte[] input, Writer output, Charset charset) copy ByteArrayInputStream in = new ByteArrayInputStream(input);
copy(in, output, charset);
|
OutputStreamWriter | createWriter(@Nullable final OutputStream aOS, @Nonnull final Charset aCharset) create Writer return aOS == null ? null : new OutputStreamWriter(aOS, aCharset); |
OutputStreamWriter | createWriter(@Nullable final OutputStream aOS, @Nonnull final String sCharset) create Writer try { return aOS == null ? null : new OutputStreamWriter(aOS, sCharset); } catch (final UnsupportedEncodingException ex) { throw new IllegalArgumentException("Failed to create Writer for charset '" + sCharset + "'", ex); |
PrintWriter | getWriter(OutputStream os, String charset) get Writer BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, Charset.forName(charset))); return new PrintWriter(writer, true); |
OutputStreamWriter | getWriter(OutputStream out, String charsetName) get Writer return getWriter(out, Charset.forName(charsetName));
|
Writer | getWriter(String fileName, Charset cs) get Writer OutputStreamWriter writer = null; try { return new OutputStreamWriter(new FileOutputStream(fileName), cs); } catch (FileNotFoundException e) { e.printStackTrace(); return writer; |
BufferedWriter | getWriter(String path, Charset encoding) Returns a writer that uses the given encoding. return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(path)), encoding)); |
PrintWriter | newFilePrintWriter(File file, Charset charset) new File Print Writer return new PrintWriter(new OutputStreamWriter(new FileOutputStream(file, true), charset)); |
BufferedWriter | newWriter(File file, Charset charset) new Writer checkNotNull(file); checkNotNull(charset); return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset)); |
Writer | newWriter(OutputStream output, Charset encoding) Creates a java.io.Writer from an output stream if (encoding != null) { return new OutputStreamWriter(output, encoding); } else { return new OutputStreamWriter(output); |