public static void write(InputStream in,OutputStream out,boolean closeBoth) throws IOException {
  byte[] buff=new byte[1024];
  int read=0;
  while ((read=in.read(buff)) > 0) {
    out.write(buff,0,read);
  }
  out.flush();
  if (closeBoth) {
    safeCloseStreams(in,out);
  }
}

public static void write ( InputStream in , OutputStream out , boolean closeBoth ) throws IOException { byte [ ] buff = new byte [ 1024 ] ; int read = 0 ; while ( ( read = in . read ( buff ) ) > 0 ) { out . write ( buff , 0 , read ) ; } out . flush ( ) ; if ( closeBoth ) { safeCloseStreams ( in , out ) ; } }
writes the input stream to the output stream . closes both if desired .
