Here you can find the source of saveToInputStream(ByteArrayInputStream in, OutputStream out)
public static void saveToInputStream(ByteArrayInputStream in, OutputStream out)
//package com.java2s; /*/*w ww .j av a 2 s . c o m*/ * Protorabbit * * Copyright (c) 2009 Greg Murray (protorabbit.org) * * Licensed under the MIT License: * * http://www.opensource.org/licenses/mit-license.php * */ import java.io.ByteArrayInputStream; import java.io.OutputStream; public class Main { public static void saveToInputStream(ByteArrayInputStream in, OutputStream out) { try { byte[] buffer = new byte[1024]; int read = 0; while (true) { read = in.read(buffer); if (read <= 0) break; out.write(buffer, 0, read); } } catch (Exception e) { System.out.println("IOUtil: error saving : " + e); e.printStackTrace(); } finally { try { if (in != null) { in.close(); } if (out != null) { out.flush(); out.close(); } } catch (Exception e) { } } } }