code: public static void copy(InputStream in, File file) throws IOException {
      OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
      try {
        IOUtils.copy(in, out);
      }
      finally {
        IOUtils.closeQuietly(out);
      }
    }
docs: Copies the given input stream into a file.
  <p>
  The target file must not be a directory and its parent must exist.
  
  @param in source stream.
  @param file output file to be created or overwritten.
  
  @throws java.io.IOException if file is not found or copying fails