hudson.util.IOUtils Java Examples
The following examples show how to use
hudson.util.IOUtils.
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 |
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: HookHandler.java From gitlab-branch-source-plugin with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") private String getRequestBody(HttpServletRequest request) throws IOException { String charset = request.getCharacterEncoding() == null ? CHARSET_UTF_8 : request.getCharacterEncoding(); String requestBody = IOUtils.toString(request.getInputStream(), charset); if (StringUtils.isBlank(requestBody)) { throw new IllegalArgumentException("request-body is empty"); } return requestBody; }
Example #3
Source File: CukedoctorBuildAction.java From cucumber-living-documentation-plugin with MIT License | 5 votes |
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 #4
Source File: DocsRenderer.java From cucumber-living-documentation-plugin with MIT License | 5 votes |
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 #5
Source File: JavaNetReverseProxy.java From jenkins-test-harness with MIT License | 5 votes |
@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 #6
Source File: JUnitTestProviderTest.java From phabricator-jenkins-plugin with MIT License | 5 votes |
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; }
Example #7
Source File: BuildImageStepExecution.java From kubernetes-pipeline-plugin with Apache License 2.0 | 4 votes |
public void visit(File file, String relativePath) throws IOException { if (recursiveMatch(dockerIgnore, file.toPath())) { return; } if (relativePath.contains("/")) { relativePath = relativePath.substring(relativePath.indexOf("/") + 1); } else { relativePath = "."; } if(Functions.isWindows()) { relativePath = relativePath.replace('\\', '/'); } if(file.isDirectory()) { relativePath += '/'; } TarArchiveEntry te = new TarArchiveEntry(file); te.setName(relativePath); int mode = IOUtils.mode(file); if (mode!=-1) { te.setMode(mode); } te.setModTime(file.lastModified()); if(!file.isDirectory()) { te.setSize(file.length()); } tar.putArchiveEntry(te); if (!file.isDirectory()) { FileInputStream in = new FileInputStream(file); try { int len; while((len=in.read(buf))>=0) tar.write(buf,0,len); } finally { in.close(); } } tar.closeArchiveEntry(); entriesWritten++; }