List of utility methods to do InputStream Read
String | readInputStream(InputStream inputStream) read Input Stream String responseLine; StringBuilder responseBuilder = new StringBuilder(); if (inputStream == null) { return responseBuilder.toString(); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream)); try { ... |
String | readInputStream(InputStream is) read Input Stream StringBuffer acc = new StringBuffer(); byte[] buf = new byte[1024]; int len; while ((len = is.read(buf)) > 0) { for (int i = 0; i < len; i++) { acc.append((char) buf[i]); is.close(); return acc.toString(); |
String | readInputStreamContent(InputStream inputStream) read Input Stream Content BufferedReader reader = new BufferedReader(new InputStreamReader( inputStream)); StringBuilder content = new StringBuilder(); try { String line = reader.readLine(); String separator = System.getProperty("line.separator"); while (line != null) { content.append(line); ... |
long | readInt(InputStream stream) read Int final byte[] tmp = new byte[4]; stream.read(tmp, 0, 4); return (((long) (tmp[0] & 0xFF)) << 24) + +((tmp[1] & 0xFF) << 16) + +((tmp[2] & 0xFF) << 8) + +(tmp[3] & 0xFF); |
long | readLong(InputStream in, final int fitInBytes) Read long which was written to fitInBytes bytes and increment position. long tmpLong = 0; for (int i = 0; i < fitInBytes; ++i) { tmpLong |= (in.read() & 0xffl) << (8 * i); return tmpLong; |
int | readShort(InputStream stream) read Short final byte[] tmp = new byte[2]; stream.read(tmp, 0, 2); return (tmp[1] & 0xFF) + ((tmp[0] & 0xFF) << 8); |
String | readStringFromInputStream(InputStream is) read String From Input Stream BufferedReader rd = new BufferedReader(new InputStreamReader(is)); StringBuilder body = new StringBuilder(); String line; while ((line = rd.readLine()) != null) { body.append(line); return body.toString(); |
String | readTextInputStream(InputStream is) read Text Input Stream if (null == is) return null; StringBuffer strbuffer = new StringBuffer(); String line; BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(is)); while ((line = reader.readLine()) != null) { ... |
String | readData(InputStream inSream, String charsetName) read Data ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len = -1; while ((len = inSream.read(buffer)) != -1) { outStream.write(buffer, 0, len); byte[] data = outStream.toByteArray(); outStream.close(); ... |
void | skip(InputStream stream, int numBytes) skip numBytes -= stream.skip(numBytes); for (; numBytes > 0; --numBytes) { if (stream.read() == -1) { throw new IOException("Unexpected end of stream"); |