Code example for ByteArrayOutputStream

Methods: closetoByteArray

0
	 * @return New array of bytes 
	 */ 
	public static byte[] toByteArray(BufferedImage image, String format) {
 
		byte[] bytes = null;
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
		try { 
			ImageIO.write(image, format, baos);
			bytes = baos.toByteArray();
		} catch (IOException e) {
			throw new WebcamException(e);
		} finally { 
			try { 
				baos.close();
			} catch (IOException e) {
				throw new WebcamException(e);
			} 
		} 
 
Contextual code suggestions in your IDE  Get Codota for Java