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

The following examples show how to use hudson.util.IOUtils#copy() . 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
Source File: CompressionTools.java    From aws-codepipeline-plugin-for-jenkins with Apache License 2.0 6 votes vote down vote up
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
Source File: CukedoctorBuildAction.java    From cucumber-living-documentation-plugin with MIT License 5 votes vote down vote up
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
Source File: DocsRenderer.java    From cucumber-living-documentation-plugin with MIT License 5 votes vote down vote up
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
Source File: JavaNetReverseProxy.java    From jenkins-test-harness with MIT License 5 votes vote down vote up
@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
Source File: JUnitTestProviderTest.java    From phabricator-jenkins-plugin with MIT License 5 votes vote down vote up
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;
}