/** * Get the contents of a <code>Reader</code> as a String. */ public static String toString(final Reader input) throws IOException { return toString(input, DEFAULT_BUFFER_SIZE); }
/** * Get the contents of a <code>byte[]</code> as a String. * The platform's default encoding is used for the byte-to-char conversion. */ public static String toString(final byte[] input) throws IOException { return toString(input, DEFAULT_BUFFER_SIZE); }
/** * Get the contents of an <code>InputStream</code> as a String. * The platform's default encoding is used for the byte-to-char conversion. */ public static String toString(final InputStream input) throws IOException { return toString(input, DEFAULT_BUFFER_SIZE); }
/** * Get the contents of an <code>InputStream</code> as a String. * @param encoding The name of a supported character encoding. See the * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. */ public static String toString(final InputStream input, final String encoding) throws IOException { return toString(input, encoding, DEFAULT_BUFFER_SIZE); }
/** * Get the contents of a <code>byte[]</code> as a String. * @param encoding The name of a supported character encoding. See the * <a href="http://www.iana.org/assignments/character-sets">IANA * Charset Registry</a> for a list of valid encoding types. */ public static String toString(final byte[] input, final String encoding) throws IOException { return toString(input, encoding, DEFAULT_BUFFER_SIZE); }
private static String getResponseBodyAsString(final Response response) throws ResponseException { // Avoids a warning in the logs about buffering a response of unknown length. // TODO: This is a DoS vector, but considered relatively safe for now, as remote JIRA must be applinked. final InputStream responseBodyStream = response.getResponseBodyAsStream(); final String charset = getCharset(response); try { return IOUtil.toString(responseBodyStream, charset); } catch (final IOException exception) { throw new ResponseException("Failed to read remote JIRA issue", exception); } }
private static String getResponseBodyAsString(final Response response) throws ResponseException { // Avoids a warning in the logs about buffering a response of unknown length. // TODO: This is a DoS vector, but considered relatively safe for now, as remote JIRA must be applinked. final InputStream responseBodyStream = response.getResponseBodyAsStream(); final String charset = getCharset(response); try { return IOUtil.toString(responseBodyStream, charset); } catch (final IOException exception) { throw new ResponseException("Failed to read remote JIRA issue", exception); } }
private static String getResponseBodyAsString(final Response response) throws ResponseException { // Avoids a warning in the logs about buffering a response of unknown length. // TODO: This is a DoS vector, but considered relatively safe for now, as remote JIRA must be applinked. final InputStream responseBodyStream = response.getResponseBodyAsStream(); final String charset = getCharset(response); try { return IOUtil.toString(responseBodyStream, charset); } catch (final IOException exception) { throw new ResponseException("Failed to read remote JIRA issue", exception); } }