public static byte[] toByteArray(Reader input, Charset encoding) throws IOException {
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        copy(input, output, encoding);
        return output.toByteArray();
    }
public static byte[] toByteArray(Reader input, Charset encoding) throws IOException {
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        copy(input, output, encoding);
        return output.toByteArray();
    }
public static byte [ ] toByteArray ( Reader input , Charset encoding ) throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream ( ) ; copy ( input , output , encoding ) ; return output . toByteArray ( ) ; }
Get the contents of a <code>Reader</code> as a <code>byte[]</code>
using the specified character encoding.
<p/>
This method buffers the input internally, so there is no need to use a
<code>BufferedReader</code>.

@param input    the <code>Reader</code> to read from
@param encoding the encoding to use, null means platform default
@return the requested byte array
@throws NullPointerException if the input is null
@throws IOException          if an I/O error occurs
@since 2.3
Get the contents of a <code > Reader< / code > as a <code > byte [] < / code > using the specified character encoding . <p / > This method buffers the input internally so there is no need to use a <code > BufferedReader< / code > .