本文整理汇总了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();
}
}
示例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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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;
}
示例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
}
示例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();
}
}
示例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());
}
}
}
}
示例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();
}