/**
  * Takes a resource on the classpath and copies it out to the file system
  *
  * @param classpathResource The classpath resource as defined as /path
  * @param outputFile The output location for the file
  */
 public static void copyFromClasspathToFileSystem(String classpathResource, File outputFile) {
   InputStream classpathInputStream = openClasspathResource(classpathResource);
   try {
     copyInputStreamToFileSystem(classpathInputStream, outputFile);
   } finally {
     closeQuietly(classpathInputStream);
   }
 }
  /**
   * Takes an already open input stream and copies to content to the file system at the specified
   * point
   *
   * @param stream The stream to copy from
   * @param outputFile The file output location
   */
  public static void copyInputStreamToFileSystem(InputStream stream, File outputFile) {
    OutputStream output = null;

    try {
      output = new FileOutputStream(outputFile);
      IOUtils.copy(stream, output);
    } catch (IOException e) {
      throw new UtilUncheckedException("Could not copy contents out to file " + outputFile, e);
    } finally {
      closeQuietly(output);
    }
  }
  public void run() {
    try {
      if (discard) {
        while (is.read() != -1) {}
      } else {
        streamToBuffer(is, out);
      }
    } catch (IOException ioe) {

      throw new RuntimeException(ioe);

    } finally {
      InputOutputUtils.closeQuietly(is);
    }
  }
 private static String slurpTextClasspathResourceToString(String resource, boolean gzipped)
     throws UtilUncheckedException {
   String output = "";
   InputStream is = null;
   try {
     if (!gzipped) {
       is = openClasspathResource(resource);
     } else {
       is = openGzippedClasspathResource(resource);
     }
     output = IOUtils.toString(is);
   } catch (IOException e) {
     throw new UtilUncheckedException(
         "IOException detected whilst streaming resource " + resource, e);
   } finally {
     closeQuietly(is);
   }
   return output;
 }