当前位置: 首页>>代码示例>>Java>>正文


Java IOUtils.copy方法代码示例

本文整理汇总了Java中hudson.util.IOUtils.copy方法的典型用法代码示例。如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java IOUtils.copy怎么用?Java IOUtils.copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hudson.util.IOUtils的用法示例。


在下文中一共展示了IOUtils.copy方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compressArchive

import hudson.util.IOUtils; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:awslabs,项目名称:aws-codepipeline-plugin-for-jenkins,代码行数:26,代码来源:CompressionTools.java

示例2: appendNote

import hudson.util.IOUtils; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void appendNote(String note, String namespace) throws GitException {
    try (Repository repo = getRepository()) {
        ObjectId head = repo.resolve(HEAD); // commit to put a note on

        ShowNoteCommand cmd = git(repo).notesShow();
        cmd.setNotesRef(qualifyNotesNamespace(namespace));
        try (ObjectReader or = repo.newObjectReader();
             RevWalk walk = new RevWalk(or)) {
            cmd.setObjectId(walk.parseAny(head));
            Note n = cmd.call();

            if (n==null) {
                addNote(note,namespace);
            } else {
                ObjectLoader ol = or.open(n.getData());
                StringWriter sw = new StringWriter();
                IOUtils.copy(new InputStreamReader(ol.openStream(),CHARSET),sw);
                sw.write("\n");
                addNote(sw.toString() + normalizeNote(note), namespace);
            }
        }
    } catch (GitAPIException | IOException e) {
        throw new GitException(e);
    }
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:27,代码来源:JGitAPIImpl.java

示例3: doPdfReport

import hudson.util.IOUtils; //导入方法依赖的package包/类
public void doPdfReport(StaplerRequest req, StaplerResponse rsp) throws IOException {
    rsp.setContentType("application/pdf");
    ServletOutputStream outputStream = rsp.getOutputStream();
    File buildDirectory = owner.getRootDir();
    File a = new File(buildDirectory, "/checkmarx/" + PDF_REPORT_NAME);

    IOUtils.copy(a, outputStream);

    outputStream.flush();
    outputStream.close();
}
 
开发者ID:jenkinsci,项目名称:checkmarx-plugin,代码行数:12,代码来源:CxScanResult.java

示例4: doOsaPdfReport

import hudson.util.IOUtils; //导入方法依赖的package包/类
public void doOsaPdfReport(StaplerRequest req, StaplerResponse rsp) throws IOException {

        rsp.setContentType("application/pdf");
        ServletOutputStream outputStream = rsp.getOutputStream();
        File buildDirectory = owner.getRootDir();
        File a = new File(buildDirectory, "/checkmarx/" + OSA_PDF_REPORT_NAME);

        IOUtils.copy(a, outputStream);

        outputStream.flush();
        outputStream.close();
    }
 
开发者ID:jenkinsci,项目名称:checkmarx-plugin,代码行数:13,代码来源:CxScanResult.java

示例5: doOsaHtmlReport

import hudson.util.IOUtils; //导入方法依赖的package包/类
public void doOsaHtmlReport(StaplerRequest req, StaplerResponse rsp) throws IOException {
    rsp.setContentType("text/html");
    ServletOutputStream outputStream = rsp.getOutputStream();
    File buildDirectory = owner.getRootDir();
    File a = new File(buildDirectory, "/checkmarx/" + "OSAReport.html");

    IOUtils.copy(a, outputStream);

    outputStream.flush();
    outputStream.close();
}
 
开发者ID:jenkinsci,项目名称:checkmarx-plugin,代码行数:12,代码来源:CxScanResult.java

示例6: doIndex

import hudson.util.IOUtils; //导入方法依赖的package包/类
/**
 * Displays the JSON payload from GitHub. Stapler API.
 *
 * @param req request
 * @param rsp response
 * @throws IOException
 */
public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException {
    rsp.setContentType("application/json;charset=UTF-8");
    // Prevent jelly from flushing stream so Content-Length header can be added afterwards
    try (FlushProofOutputStream out = new FlushProofOutputStream(rsp.getCompressedOutputStream(req))) {
        IOUtils.copy(getPayloadFile(), out);
    }
}
 
开发者ID:Affirm,项目名称:jenkins-plugins,代码行数:15,代码来源:TagCause.java

示例7: getTestResult

import hudson.util.IOUtils; //导入方法依赖的package包/类
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;
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:11,代码来源:JUnitTestProviderTest.java

示例8: downloadBundle

import hudson.util.IOUtils; //导入方法依赖的package包/类
private void downloadBundle(String s) throws IOException, SAXException {
    JenkinsRule.JSONWebResponse jsonWebResponse = rule.postJSON(root.getUrlName() + s, "");
    File zipFile = File.createTempFile("test", "zip");
    IOUtils.copy(jsonWebResponse.getContentAsStream(), zipFile);
    ZipFile z = new ZipFile(zipFile);
    // Zip file is valid
}
 
开发者ID:jenkinsci,项目名称:support-core-plugin,代码行数:8,代码来源:SupportActionTest.java

示例9: unzip

import hudson.util.IOUtils; //导入方法依赖的package包/类
private static void unzip(File dir, InputStream in) throws IOException {
  File tmpFile = File.createTempFile("tmpzip", null); // uses java.io.tmpdir
  try {
      IOUtils.copy(in, tmpFile);
      unzip(dir,tmpFile);
  }
  finally {
      tmpFile.delete();
  }
}
 
开发者ID:jenkinsci,项目名称:cloudtest-plugin,代码行数:11,代码来源:CommonInstaller.java

示例10: takeSnapshotAndMakeSureSomethingHappens

import hudson.util.IOUtils; //导入方法依赖的package包/类
/**
 * Integration test that simulates the user action of clicking the button to generate the bundle.
 *
 * <p>
 * If any warning is reported to j.u.l logger, treat that as a sign of failure, because
 * support-core plugin works darn hard to try to generate something in the presence of failing
 * {@link Component} impls.
 */
@Test
public void takeSnapshotAndMakeSureSomethingHappens() throws Exception {
    rule.createSlave("slave1","test",null).getComputer().connect(false).get();
    rule.createSlave("slave2","test",null).getComputer().connect(false).get();

    RingBufferLogHandler checker = new RingBufferLogHandler();
    Logger logger = Logger.getLogger(SupportPlugin.class.getPackage().getName());

    logger.addHandler(checker);

    try {
        WebClient wc = rule.createWebClient();
        HtmlPage p = wc.goTo(root.getUrlName());

        HtmlForm form = p.getFormByName("bundle-contents");
        HtmlButton submit = (HtmlButton) form.getHtmlElementsByTagName("button").get(0);
        Page zip = submit.click();
        File zipFile = File.createTempFile("test", "zip");
        IOUtils.copy(zip.getWebResponse().getContentAsStream(), zipFile);

        ZipFile z = new ZipFile(zipFile);

        // check the presence of files
        // TODO: emit some log entries and see if it gets captured here
        assertNotNull(z.getEntry("about.md"));
        assertNotNull(z.getEntry("nodes.md"));
        assertNotNull(z.getEntry("nodes/master/thread-dump.txt"));

        if (SystemPlatform.LINUX == SystemPlatform.current()) {
            List<String> files = Arrays.asList("proc/swaps.txt",
                                                   "proc/cpuinfo.txt",
                                                   "proc/mounts.txt",
                                                   "proc/system-uptime.txt",
                                                   "proc/net/rpc/nfs.txt",
                                                   "proc/net/rpc/nfsd.txt",
                                                   "proc/meminfo.txt",
                                                   "proc/self/status.txt",
                                                   "proc/self/cmdline",
                                                   "proc/self/environ",
                                                   "proc/self/limits.txt",
                                                   "proc/self/mountstats.txt",
                                                   "sysctl.txt",
                                                   "dmesg.txt",
                                                   "userid.txt",
                                                   "dmi.txt");

            for (String file : files) {
                assertNotNull(file +" was not found in the bundle",
                              z.getEntry("nodes/master/"+file));
            }
        }
    } finally {
        logger.removeHandler(checker);
        for (LogRecord r : checker.getView()) {
            if (r.getLevel().intValue() >= Level.WARNING.intValue()) {
                Throwable thrown = r.getThrown();
                if (thrown != null)
                    thrown.printStackTrace(System.err);

                fail(r.getMessage());
            }
        }
    }
}
 
开发者ID:jenkinsci,项目名称:support-core-plugin,代码行数:73,代码来源:SupportActionTest.java

示例11: doIndex

import hudson.util.IOUtils; //导入方法依赖的package包/类
/**
 * This is the method Hudson uses when a dynamic png is referenced in a jelly file.
 *
 * @param req
 * @param rsp
 * @throws IOException
 */
public void doIndex(final StaplerRequest req, final StaplerResponse rsp) throws IOException {
	rsp.setContentType("image/png");
	final ServletOutputStream os = rsp.getOutputStream();
	IOUtils.copy(file, os);
	os.close();
}
 
开发者ID:jenkinsci,项目名称:neoload-plugin,代码行数:14,代码来源:ProjectSpecificAction.java


注:本文中的hudson.util.IOUtils.copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。