public static void copyStream(InputStream inputStream,OutputStream outputStream,boolean closeOut) throws IOException {
  try {
    copyBytesToStream(inputStream,outputStream,-1);
  }
  finally {
    try {
      inputStream.close();
    }
  finally {
      if (closeOut) {
        outputStream.close();
      }
    }
  }
}

public static void copyStream ( InputStream inputStream , OutputStream outputStream , boolean closeOut ) throws IOException { try { copyBytesToStream ( inputStream , outputStream , - 1 ) ; } finally { try { inputStream . close ( ) ; } finally { if ( closeOut ) { outputStream . close ( ) ; } } } }
copies all bytes in given inputstream ( until eof ) to given outputstream . closes inputstream and also outputstream if given closeout is true .
