hudson.Util.copyStreamAndClose()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(237)

本文整理了Java中hudson.Util.copyStreamAndClose()方法的一些代码示例,展示了Util.copyStreamAndClose()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.copyStreamAndClose()方法的具体详情如下:
包路径:hudson.Util
类名称:Util
方法名:copyStreamAndClose

Util.copyStreamAndClose介绍

暂无

代码示例

代码示例来源:origin: org.jenkins-ci.plugins.uithemes/uithemes-processor

  1. private static String loadLESSTemplateText(String templatePath, Class<?> loaderClass) {
  2. InputStream templateResStream = loaderClass.getResourceAsStream(templatePath);
  3. if (templateResStream != null) {
  4. try {
  5. Reader templateResStreamReader = new InputStreamReader(templateResStream, "UTF-8");
  6. StringWriter writer = new StringWriter();
  7. Util.copyStreamAndClose(templateResStreamReader, writer);
  8. return writer.toString();
  9. } catch (IOException e) {
  10. LOGGER.log(Level.WARNING, String.format("Error reading LESS resource template file '%s'.", templatePath), e);
  11. }
  12. } else {
  13. LOGGER.log(Level.INFO, "No UI Theme Contribution LESS template found at ''{0}'' on the classpath.", templatePath);
  14. }
  15. return null;
  16. }
  17. }

代码示例来源:origin: org.jenkins-ci.plugins.uithemes/uithemes-processor

  1. public static <T> T fromRequest(StaplerRequest req, Class<T> to) throws IOException {
  2. String contentEncoding = req.getCharacterEncoding();
  3. StringWriter writer = new StringWriter();
  4. if (contentEncoding == null) {
  5. contentEncoding = "UTF-8";
  6. }
  7. Util.copyStreamAndClose(new InputStreamReader(req.getInputStream(), contentEncoding), writer);
  8. return fromString(writer.toString(), to);
  9. }

代码示例来源:origin: org.jenkins-ci.plugins/scriptler

  1. @Override
  2. public String getScriptSource(ScriptInfo scriptInfo) {
  3. try {
  4. final String scriptUrl = CATALOG_INFO.getReplacedDownloadUrl(scriptInfo.getName(), scriptInfo.getId());
  5. ByteArrayOutputStream out = new ByteArrayOutputStream();
  6. Util.copyStreamAndClose(ProxyConfiguration.open(new URL(scriptUrl)).getInputStream(), out);
  7. return out.toString("UTF-8");
  8. } catch (Exception e) {
  9. LOGGER.log(Level.SEVERE, "not abe to load script sources from GH for: " + scriptInfo, e);
  10. }
  11. return null;
  12. }
  13. }

代码示例来源:origin: org.eclipse.hudson/hudson-core

  1. private void testConnection(URL url) throws IOException {
  2. try {
  3. Util.copyStreamAndClose(ProxyConfiguration.open(url).getInputStream(), new NullOutputStream());
  4. } catch (SSLHandshakeException e) {
  5. if (e.getMessage().contains("PKIX path building failed")) // fix up this illegible error message from JDK
  6. {
  7. throw new IOException2("Failed to validate the SSL certificate of " + url, e);
  8. }
  9. }
  10. }
  11. }

代码示例来源:origin: jenkinsci/maven-plugin

  1. /**
  2. * Gets the artifact as a local file, perhaps creating a temporary copy as needed.
  3. * You must {@link #close} it when finished; do not delete the result file yourself.
  4. * @return either the original artifact, or a copy thereof; may not exist if it has since been deleted
  5. */
  6. public @Nonnull synchronized File getFile() throws IOException {
  7. if (copy == null) {
  8. try {
  9. return MavenArtifact.this.getFile(build);
  10. } catch (FileNotFoundException x) {
  11. File f = File.createTempFile("jenkins-", canonicalName);
  12. f.deleteOnExit();
  13. OutputStream os = new FileOutputStream(f);
  14. try {
  15. Util.copyStreamAndClose(getVirtualFile().open(), os);
  16. } finally {
  17. os.close();
  18. }
  19. copy = f;
  20. }
  21. }
  22. return copy;
  23. }

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

  1. private void testConnection(URL url) throws IOException {
  2. try {
  3. Util.copyStreamAndClose(ProxyConfiguration.open(url).getInputStream(),new NullOutputStream());
  4. } catch (SSLHandshakeException e) {
  5. if (e.getMessage().contains("PKIX path building failed"))
  6. // fix up this crappy error message from JDK
  7. throw new IOException2("Failed to validate the SSL certificate of "+url,e);
  8. }
  9. }
  10. }

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

  1. private void testConnection(URL url) throws IOException {
  2. try {
  3. Util.copyStreamAndClose(ProxyConfiguration.open(url).getInputStream(),new NullOutputStream());
  4. } catch (SSLHandshakeException e) {
  5. if (e.getMessage().contains("PKIX path building failed"))
  6. // fix up this illegible error message from JDK
  7. throw new IOException2("Failed to validate the SSL certificate of "+url,e);
  8. }
  9. }
  10. }

代码示例来源:origin: hudson/hudson-2.x

  1. private void testConnection(URL url) throws IOException {
  2. try {
  3. Util.copyStreamAndClose(ProxyConfiguration.open(url).getInputStream(),new NullOutputStream());
  4. } catch (SSLHandshakeException e) {
  5. if (e.getMessage().contains("PKIX path building failed"))
  6. // fix up this crappy error message from JDK
  7. throw new IOException2("Failed to validate the SSL certificate of "+url,e);
  8. }
  9. }
  10. }

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

  1. private void copySlaveJar(PrintStream logger, SmbFile remoteRoot) throws IOException {
  2. // copy slave.jar
  3. logger.println("Copying slave.jar");
  4. copyStreamAndClose(Hudson.getInstance().getJnlpJars("slave.jar").getURL().openStream(), new SmbFile(remoteRoot,"slave.jar").getOutputStream());
  5. }

代码示例来源:origin: hudson/hudson-2.x

  1. private void copySlaveJar(PrintStream logger, SmbFile remoteRoot) throws IOException {
  2. // copy slave.jar
  3. logger.println("Copying slave.jar");
  4. copyStreamAndClose(Hudson.getInstance().getJnlpJars("slave.jar").getURL().openStream(), new SmbFile(remoteRoot,"slave.jar").getOutputStream());
  5. }

代码示例来源:origin: org.jenkins-ci.plugins/ssh-slaves

  1. Util.copyStreamAndClose(bundle.openStream(),new BufferedOutputStream(sftp.writeToFile(bundleFile),32*1024));
  2. sftp.chmod(bundleFile,0755);

代码示例来源:origin: jenkinsci/maven-plugin

  1. @Override public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
  2. rsp.setContentType("application/octet-stream");
  3. Util.copyStreamAndClose(parent.parent.getArtifactManager().root().child(artifactPath()).open(), rsp.getCompressedOutputStream(req));
  4. }
  5. };

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

  1. copyStreamAndClose(getClass().getResource("/windows-service/hudson.exe").openStream(), new SmbFile(remoteRoot,"hudson-slave.exe").getOutputStream());
  2. copyStreamAndClose(new ByteArrayInputStream(xml.getBytes("UTF-8")), new SmbFile(remoteRoot,"hudson-slave.xml").getOutputStream());

代码示例来源:origin: hudson/hudson-2.x

  1. copyStreamAndClose(getClass().getResource("/windows-service/hudson.exe").openStream(), new SmbFile(remoteRoot,"hudson-slave.exe").getOutputStream());
  2. copyStreamAndClose(new ByteArrayInputStream(xml.getBytes("UTF-8")), new SmbFile(remoteRoot,"hudson-slave.xml").getOutputStream());

相关文章