Java Utililty Methods InputStream Read by Charset

List of utility methods to do InputStream Read by Charset

Description

The list of methods to do InputStream Read by Charset are organized into topic(s).

Method

StringstreamToString(final InputStream is, final Charset charset)
stream To String
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) != -1) {
    bos.write(buffer, 0, length);
return bos.toString(charset.name());
StringstreamToString(InputStream inputStream, Charset encoding)
stream To String
final int bufferSize = 1024;
final char[] buffer = new char[bufferSize];
final StringBuilder out = new StringBuilder();
Reader in = new InputStreamReader(inputStream, encoding);
for (;;) {
    int rsz = in.read(buffer, 0, buffer.length);
    if (rsz < 0)
        break;
...
StringstringFromStream(InputStream in, Charset cs)
string From Stream
char[] buf = new char[256];
StringBuffer result = new StringBuffer();
Reader cis = new InputStreamReader(in);
int read = 0;
while ((read = cis.read(buf, 0, buf.length)) > 0) {
    result.append(buf, 0, read);
in.close();
...
InputStreamtoInputStream(final String string, final Charset charset)
Build an input stream from the specified string in the encoding specified.
return new ByteArrayInputStream(string.getBytes(charset));
InputStreamtoInputStream(String input, Charset charset)
Convert the given string as an input stream that contains the string using the specified charset.
return (input != null && charset != null) ? new ByteArrayInputStream(input.getBytes(charset)) : null;
InputStreamtoInputStream(String input, Charset cs)
to Input Stream
return new ByteArrayInputStream(input.getBytes(cs));
StringtoString(final InputStream input, final Charset encoding)
to String
return toString(new InputStreamReader(input, encoding));
StringtoString(InputStream in, Charset charset)
to String
return toString(new InputStreamReader(in, charset));
StringtoString(InputStream in, Charset charset)
to String
ByteArrayOutputStream bais = new ByteArrayOutputStream(DEFAULT_BUFFER_SIZE);
copy(in, bais, charset);
return new String(bais.toByteArray());
StringtoString(InputStream in, Charset charset)
to String
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(in, charset));
try {
    String str = null;
    while (null != (str = br.readLine())) {
        sb.append(str).append(System.getProperty("line.separator"));
} catch (IOException e) {
...