本文整理了Java中hudson.Util.copyStreamAndClose()
方法的一些代码示例,展示了Util.copyStreamAndClose()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.copyStreamAndClose()
方法的具体详情如下:
包路径:hudson.Util
类名称:Util
方法名:copyStreamAndClose
暂无
代码示例来源:origin: org.jenkins-ci.plugins.uithemes/uithemes-processor
private static String loadLESSTemplateText(String templatePath, Class<?> loaderClass) {
InputStream templateResStream = loaderClass.getResourceAsStream(templatePath);
if (templateResStream != null) {
try {
Reader templateResStreamReader = new InputStreamReader(templateResStream, "UTF-8");
StringWriter writer = new StringWriter();
Util.copyStreamAndClose(templateResStreamReader, writer);
return writer.toString();
} catch (IOException e) {
LOGGER.log(Level.WARNING, String.format("Error reading LESS resource template file '%s'.", templatePath), e);
}
} else {
LOGGER.log(Level.INFO, "No UI Theme Contribution LESS template found at ''{0}'' on the classpath.", templatePath);
}
return null;
}
}
代码示例来源:origin: org.jenkins-ci.plugins.uithemes/uithemes-processor
public static <T> T fromRequest(StaplerRequest req, Class<T> to) throws IOException {
String contentEncoding = req.getCharacterEncoding();
StringWriter writer = new StringWriter();
if (contentEncoding == null) {
contentEncoding = "UTF-8";
}
Util.copyStreamAndClose(new InputStreamReader(req.getInputStream(), contentEncoding), writer);
return fromString(writer.toString(), to);
}
代码示例来源:origin: org.jenkins-ci.plugins/scriptler
@Override
public String getScriptSource(ScriptInfo scriptInfo) {
try {
final String scriptUrl = CATALOG_INFO.getReplacedDownloadUrl(scriptInfo.getName(), scriptInfo.getId());
ByteArrayOutputStream out = new ByteArrayOutputStream();
Util.copyStreamAndClose(ProxyConfiguration.open(new URL(scriptUrl)).getInputStream(), out);
return out.toString("UTF-8");
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "not abe to load script sources from GH for: " + scriptInfo, e);
}
return null;
}
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
private void testConnection(URL url) throws IOException {
try {
Util.copyStreamAndClose(ProxyConfiguration.open(url).getInputStream(), new NullOutputStream());
} catch (SSLHandshakeException e) {
if (e.getMessage().contains("PKIX path building failed")) // fix up this illegible error message from JDK
{
throw new IOException2("Failed to validate the SSL certificate of " + url, e);
}
}
}
}
代码示例来源:origin: jenkinsci/maven-plugin
/**
* Gets the artifact as a local file, perhaps creating a temporary copy as needed.
* You must {@link #close} it when finished; do not delete the result file yourself.
* @return either the original artifact, or a copy thereof; may not exist if it has since been deleted
*/
public @Nonnull synchronized File getFile() throws IOException {
if (copy == null) {
try {
return MavenArtifact.this.getFile(build);
} catch (FileNotFoundException x) {
File f = File.createTempFile("jenkins-", canonicalName);
f.deleteOnExit();
OutputStream os = new FileOutputStream(f);
try {
Util.copyStreamAndClose(getVirtualFile().open(), os);
} finally {
os.close();
}
copy = f;
}
}
return copy;
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
private void testConnection(URL url) throws IOException {
try {
Util.copyStreamAndClose(ProxyConfiguration.open(url).getInputStream(),new NullOutputStream());
} catch (SSLHandshakeException e) {
if (e.getMessage().contains("PKIX path building failed"))
// fix up this crappy error message from JDK
throw new IOException2("Failed to validate the SSL certificate of "+url,e);
}
}
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
private void testConnection(URL url) throws IOException {
try {
Util.copyStreamAndClose(ProxyConfiguration.open(url).getInputStream(),new NullOutputStream());
} catch (SSLHandshakeException e) {
if (e.getMessage().contains("PKIX path building failed"))
// fix up this illegible error message from JDK
throw new IOException2("Failed to validate the SSL certificate of "+url,e);
}
}
}
代码示例来源:origin: hudson/hudson-2.x
private void testConnection(URL url) throws IOException {
try {
Util.copyStreamAndClose(ProxyConfiguration.open(url).getInputStream(),new NullOutputStream());
} catch (SSLHandshakeException e) {
if (e.getMessage().contains("PKIX path building failed"))
// fix up this crappy error message from JDK
throw new IOException2("Failed to validate the SSL certificate of "+url,e);
}
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
private void copySlaveJar(PrintStream logger, SmbFile remoteRoot) throws IOException {
// copy slave.jar
logger.println("Copying slave.jar");
copyStreamAndClose(Hudson.getInstance().getJnlpJars("slave.jar").getURL().openStream(), new SmbFile(remoteRoot,"slave.jar").getOutputStream());
}
代码示例来源:origin: hudson/hudson-2.x
private void copySlaveJar(PrintStream logger, SmbFile remoteRoot) throws IOException {
// copy slave.jar
logger.println("Copying slave.jar");
copyStreamAndClose(Hudson.getInstance().getJnlpJars("slave.jar").getURL().openStream(), new SmbFile(remoteRoot,"slave.jar").getOutputStream());
}
代码示例来源:origin: org.jenkins-ci.plugins/ssh-slaves
Util.copyStreamAndClose(bundle.openStream(),new BufferedOutputStream(sftp.writeToFile(bundleFile),32*1024));
sftp.chmod(bundleFile,0755);
代码示例来源:origin: jenkinsci/maven-plugin
@Override public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
rsp.setContentType("application/octet-stream");
Util.copyStreamAndClose(parent.parent.getArtifactManager().root().child(artifactPath()).open(), rsp.getCompressedOutputStream(req));
}
};
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
copyStreamAndClose(getClass().getResource("/windows-service/hudson.exe").openStream(), new SmbFile(remoteRoot,"hudson-slave.exe").getOutputStream());
copyStreamAndClose(new ByteArrayInputStream(xml.getBytes("UTF-8")), new SmbFile(remoteRoot,"hudson-slave.xml").getOutputStream());
代码示例来源:origin: hudson/hudson-2.x
copyStreamAndClose(getClass().getResource("/windows-service/hudson.exe").openStream(), new SmbFile(remoteRoot,"hudson-slave.exe").getOutputStream());
copyStreamAndClose(new ByteArrayInputStream(xml.getBytes("UTF-8")), new SmbFile(remoteRoot,"hudson-slave.xml").getOutputStream());
内容来源于网络,如有侵权,请联系作者删除!