Java Code Examples for hudson.util.IOUtils#copy()

The following examples show how to use hudson.util.IOUtils#copy() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private static void compressArchive(
        final Path pathToCompress,
        final ArchiveOutputStream archiveOutputStream,
        final ArchiveEntryFactory archiveEntryFactory,
        final CompressionType compressionType,
        final BuildListener listener)
        throws IOException {
    final List<File> files = addFilesToCompress(pathToCompress, listener);

    LoggingHelper.log(listener, "Compressing directory '%s' as a '%s' archive",
            pathToCompress.toString(),
            compressionType.name());

    for (final File file : files) {
        final String newTarFileName = pathToCompress.relativize(file.toPath()).toString();
        final ArchiveEntry archiveEntry = archiveEntryFactory.create(file, newTarFileName);
        archiveOutputStream.putArchiveEntry(archiveEntry);

        try (final FileInputStream fileInputStream = new FileInputStream(file)) {
            IOUtils.copy(fileInputStream, archiveOutputStream);
        }

        archiveOutputStream.closeArchiveEntry();
    }
}
 
Example 2
private void createAllDocsPage(File allDocsPath) {
    if (!allDocsPath.exists()) {
        try (InputStream is = getClass().getResourceAsStream("/" + CukedoctorBaseAction.BUILD_ACTION_ALL_DOCUMENTATION)) {
            IOUtils.copy(is, allDocsPath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
 
Example 3
private void createAllDocsPage(File allDocsPath) {
    if (!allDocsPath.exists()) {
        try (InputStream is = getClass().getResourceAsStream("/" + CukedoctorBaseAction.ALL_DOCUMENTATION)) {
            IOUtils.copy(is, allDocsPath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
 
Example 4
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String path = req.getServletPath();
    String d = Util.getDigestOf(path);

    File cache = new File(cacheFolder, d);
    if(!cache.exists()) {
        URL url = new URL("http://updates.jenkins-ci.org/" + path);
        FileUtils.copyURLToFile(url,cache);
    }

    resp.setContentType(getMimeType(path));
    IOUtils.copy(cache,resp.getOutputStream());
}
 
Example 5
private TestResult getTestResult() throws IOException {
    File temp = File.createTempFile("anything", "xml");
    temp.deleteOnExit();
    InputStream junit = getClass().getResourceAsStream("go-torch-junit.xml");

    IOUtils.copy(junit, temp);
    TestResult result = new TestResult();
    result.parse(temp);
    return result;
}