List of usage examples for org.apache.commons.io Charsets toCharset
public static Charset toCharset(String charset)
From source file:launcher.net.CustomIOUtils.java
/** * Writes chars from a <code>CharSequence</code> to bytes on an * <code>OutputStream</code> using the specified character encoding. * <p>/*from w ww . j ava 2 s . c o m*/ * Character encoding names can be found at * <a href="http://www.iana.org/assignments/character-sets">IANA</a>. * <p> * This method uses {@link String#getBytes(String)}. * * @param data the <code>CharSequence</code> to write, null ignored * @param output the <code>OutputStream</code> to write to * @param encoding the encoding to use, null means platform default * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs * @throws UnsupportedCharsetException * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not * supported. * @since 2.0 */ public static void write(CharSequence data, OutputStream output, String encoding) throws IOException { write(data, output, Charsets.toCharset(encoding)); }
From source file:com.tomagoyaky.jdwp.IOUtils.java
/** * Writes chars from a <code>CharSequence</code> to bytes on an * <code>OutputStream</code> using the specified character encoding. * <p/>/*from w ww. j ava2 s .c o m*/ * Character encoding names can be found at * <a href="http://www.iana.org/assignments/character-sets">IANA</a>. * <p/> * This method uses {@link String#getBytes(String)}. * * @param data the <code>CharSequence</code> to write, null ignored * @param output the <code>OutputStream</code> to write to * @param encoding the encoding to use, null means platform default * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported. * @since 2.0 */ public static void write(final CharSequence data, final OutputStream output, final String encoding) throws IOException { write(data, output, Charsets.toCharset(encoding)); }
From source file:launcher.net.CustomIOUtils.java
/** * Writes chars from a <code>String</code> to bytes on an * <code>OutputStream</code> using the specified character encoding. * <p>/*from ww w. j a v a 2 s . co m*/ * This method uses {@link String#getBytes(String)}. * * @param data the <code>String</code> to write, null ignored * @param output the <code>OutputStream</code> to write to * @param encoding the encoding to use, null means platform default * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs * @since 2.3 */ public static void write(String data, OutputStream output, Charset encoding) throws IOException { if (data != null) { output.write(data.getBytes(Charsets.toCharset(encoding))); } }
From source file:launcher.net.CustomIOUtils.java
/** * Writes chars from a <code>String</code> to bytes on an * <code>OutputStream</code> using the specified character encoding. * <p>//from ww w . j a v a 2 s . com * Character encoding names can be found at * <a href="http://www.iana.org/assignments/character-sets">IANA</a>. * <p> * This method uses {@link String#getBytes(String)}. * * @param data the <code>String</code> to write, null ignored * @param output the <code>OutputStream</code> to write to * @param encoding the encoding to use, null means platform default * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs * @throws UnsupportedCharsetException * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not * supported. * @since 1.1 */ public static void write(String data, OutputStream output, String encoding) throws IOException { write(data, output, Charsets.toCharset(encoding)); }
From source file:com.tomagoyaky.jdwp.IOUtils.java
/** * Writes chars from a <code>String</code> to bytes on an * <code>OutputStream</code> using the specified character encoding. * <p/>//from w w w. j ava 2s .co m * This method uses {@link String#getBytes(String)}. * * @param data the <code>String</code> to write, null ignored * @param output the <code>OutputStream</code> to write to * @param encoding the encoding to use, null means platform default * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs * @since 2.3 */ public static void write(final String data, final OutputStream output, final Charset encoding) throws IOException { if (data != null) { output.write(data.getBytes(Charsets.toCharset(encoding))); } }
From source file:com.tomagoyaky.jdwp.IOUtils.java
/** * Writes chars from a <code>String</code> to bytes on an * <code>OutputStream</code> using the specified character encoding. * <p/>//from w ww. j a v a2s.c om * Character encoding names can be found at * <a href="http://www.iana.org/assignments/character-sets">IANA</a>. * <p/> * This method uses {@link String#getBytes(String)}. * * @param data the <code>String</code> to write, null ignored * @param output the <code>OutputStream</code> to write to * @param encoding the encoding to use, null means platform default * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported. * @since 1.1 */ public static void write(final String data, final OutputStream output, final String encoding) throws IOException { write(data, output, Charsets.toCharset(encoding)); }
From source file:launcher.net.CustomIOUtils.java
/** * Writes chars from a <code>StringBuffer</code> to bytes on an * <code>OutputStream</code> using the specified character encoding. * <p>//from w w w . j av a 2s . com * Character encoding names can be found at * <a href="http://www.iana.org/assignments/character-sets">IANA</a>. * <p> * This method uses {@link String#getBytes(String)}. * * @param data the <code>StringBuffer</code> to write, null ignored * @param output the <code>OutputStream</code> to write to * @param encoding the encoding to use, null means platform default * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs * @throws UnsupportedCharsetException * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not * supported. * @since 1.1 * @deprecated replaced by write(CharSequence, OutputStream, String) */ @Deprecated public static void write(StringBuffer data, OutputStream output, String encoding) throws IOException { if (data != null) { output.write(data.toString().getBytes(Charsets.toCharset(encoding))); } }
From source file:launcher.net.CustomIOUtils.java
/** * Writes the <code>toString()</code> value of each item in a collection to * an <code>OutputStream</code> line by line, using the specified character * encoding and the specified line ending. * * @param lines the lines to write, null entries produce blank lines * @param lineEnding the line separator to use, null is system default * @param output the <code>OutputStream</code> to write to, not null, not closed * @param encoding the encoding to use, null means platform default * @throws NullPointerException if the output is null * @throws IOException if an I/O error occurs * @since 2.3/*from www . j ava 2s .co m*/ */ public static void writeLines(Collection<?> lines, String lineEnding, OutputStream output, Charset encoding) throws IOException { if (lines == null) { return; } if (lineEnding == null) { lineEnding = LINE_SEPARATOR; } Charset cs = Charsets.toCharset(encoding); for (Object line : lines) { if (line != null) { output.write(line.toString().getBytes(cs)); } output.write(lineEnding.getBytes(cs)); } }
From source file:com.tomagoyaky.jdwp.IOUtils.java
/** * Writes chars from a <code>StringBuffer</code> to bytes on an * <code>OutputStream</code> using the specified character encoding. * <p/>/*from w w w. j ava 2 s. c om*/ * Character encoding names can be found at * <a href="http://www.iana.org/assignments/character-sets">IANA</a>. * <p/> * This method uses {@link String#getBytes(String)}. * * @param data the <code>StringBuffer</code> to write, null ignored * @param output the <code>OutputStream</code> to write to * @param encoding the encoding to use, null means platform default * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported. * @since 1.1 * @deprecated replaced by write(CharSequence, OutputStream, String) */ @Deprecated public static void write(final StringBuffer data, final OutputStream output, final String encoding) throws IOException { if (data != null) { output.write(data.toString().getBytes(Charsets.toCharset(encoding))); } }
From source file:launcher.net.CustomIOUtils.java
/** * Writes the <code>toString()</code> value of each item in a collection to * an <code>OutputStream</code> line by line, using the specified character * encoding and the specified line ending. * <p>/*from w w w .j av a 2 s. c o m*/ * Character encoding names can be found at * <a href="http://www.iana.org/assignments/character-sets">IANA</a>. * * @param lines the lines to write, null entries produce blank lines * @param lineEnding the line separator to use, null is system default * @param output the <code>OutputStream</code> to write to, not null, not closed * @param encoding the encoding to use, null means platform default * @throws NullPointerException if the output is null * @throws IOException if an I/O error occurs * @throws UnsupportedCharsetException * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not * supported. * @since 1.1 */ public static void writeLines(Collection<?> lines, String lineEnding, OutputStream output, String encoding) throws IOException { writeLines(lines, lineEnding, output, Charsets.toCharset(encoding)); }