/** * Calls the write(byte[]) method. * * @see java.io.OutputStream#write(int) */ @Override public synchronized void write(final int b) { write(new byte[] { (byte)b }, 0, 1); }
/** * Calls the write(byte[]) method. * * @see java.io.OutputStream#write(int) */ public synchronized void write(int b) { write(new byte[] { (byte)b }, 0, 1); }
/** * Calls the write(byte[]) method. * * @see java.io.OutputStream#write(int) */ @Override public synchronized void write(int b) { write(new byte[] { (byte)b }, 0, 1); }
public static byte[] obtainByteData(InputStream is) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); byte[] bytes = new byte[512]; // Read bytes from the input stream in bytes.length-sized chunks and write // them into the output stream int readBytes; while ((readBytes = is.read(bytes)) > 0) { os.write(bytes, 0, readBytes); } // Convert the contents of the output stream into a byte array byte[] byteData = os.toByteArray(); // Close the streams is.close(); os.close(); return byteData; }
@Override protected byte[] readAllResources(List<IResourceStream> resources) throws IOException, ResourceStreamNotFoundException { ByteArrayOutputStream output = new ByteArrayOutputStream(); for (IResourceStream curStream : resources) { IOUtils.copy(curStream.getInputStream(), output); output.write(";".getBytes()); } byte[] bytes = output.toByteArray(); if (getCompressor() != null) { String nonCompressed = new String(bytes, "UTF-8"); bytes = getCompressor().compress(nonCompressed).getBytes("UTF-8"); } return bytes; }