List of utility methods to do InputStream to Byte Array
int | fread(short[] data, int length, InputStream fp) Read data from fp .
byte[] bytes = new byte[2]; int readLength = 0; for (int i = 0; i < length; i++) { if (fp.read(bytes) != 2) break; data[i] = (short) ((bytes[1] << 8) | (bytes[0] & 0x00FF)); readLength++; return readLength; |
byte[] | getBytes(InputStream attachment) Reads all bytes from an InputStream ByteArrayOutputStream read = new ByteArrayOutputStream(); copyBuffer(attachment, read, 2056); return read.toByteArray(); |
byte[] | getBytes(InputStream fis) get Bytes byte[] buffer = null; try { ByteArrayOutputStream bos = new ByteArrayOutputStream(1000); byte[] b = new byte[1000]; int n; while ((n = fis.read(b)) != -1) { bos.write(b, 0, n); fis.close(); bos.close(); buffer = bos.toByteArray(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); return buffer; |
byte[] | getBytes(InputStream in) get Bytes ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] b = new byte[1024]; int n; try { while ((n = in.read(b)) != -1) { out.write(b, 0, n); } catch (IOException unlikely) { ... |
byte[] | getBytes(InputStream in) get Bytes ByteArrayOutputStream out = new ByteArrayOutputStream(); copy(in, out); return out.toByteArray(); |
byte[] | getBytes(InputStream in) get Bytes List<byte[]> chunks = new ArrayList<byte[]>(); int sum = 0; while (true) { byte[] chunk = new byte[1024]; int n = in.read(chunk); if (n < 0) break; else if (n > 0) { ... |
byte[] | getBytes(InputStream in) Gets a byte array for the given input stream. ByteArrayOutputStream out = new ByteArrayOutputStream(); pipeStream(in, out, 4096); return out.toByteArray(); |
byte[] | getBytes(InputStream in) Given the supplied InputStream read all the bytes from it and return them as a byte array. return getBytes(in, false);
|
byte[] | getBytes(InputStream in, int length, int BUF_SIZE) get Bytes byte[] classbytes; int bytesread = 0; int readcount; try { if (length > 0) { classbytes = new byte[length]; for (; bytesread < length; bytesread += readcount) { readcount = in.read(classbytes, bytesread, length - bytesread); ... |
void | getBytes(InputStream in, OutputStream out) get Bytes byte[] buf = new byte[10000]; for (int bytesRead = in.read(buf); bytesRead > -1; bytesRead = in.read(buf)) { out.write(buf, 0, bytesRead); out.flush(); |