public static void copy(InputStream in,boolean closeIn,OutputStream out,boolean closeOut) throws IOException {
  try {
    try {
      IOUtils.copy(in,out);
    }
  finally {
      if (closeIn)       IOUtils.closeQuietly(in);
    }
  }
  finally {
    if (closeOut)     IOUtils.closeQuietly(out);
  }
}

public static void copy ( InputStream in , boolean closeIn , OutputStream out , boolean closeOut ) throws IOException { try { try { IOUtils . copy ( in , out ) ; } finally { if ( closeIn ) IOUtils . closeQuietly ( in ) ; } } finally { if ( closeOut ) IOUtils . closeQuietly ( out ) ; } }
copy an inputstream to an outputstream , optionally closing either the input or the output .
