private void unzip(File dir, InputStream in) throws IOException { File tmpFile = File.createTempFile("tmpzip", null); // uses java.io.tmpdir try { // TODO why does this not simply use ZipInputStream? IOUtils.copy(in, tmpFile); unzip(dir,tmpFile); } finally { tmpFile.delete(); } }
/** * Writes {@code config.xml} to the specified output stream. * The user must have at least {@link #EXTENDED_READ}. * If he lacks {@link #CONFIGURE}, then any {@link Secret}s detected will be masked out. */ @Restricted(NoExternalUse.class) public void writeConfigDotXml(OutputStream os) throws IOException { checkPermission(EXTENDED_READ); XmlFile configFile = getConfigFile(); if (hasPermission(CONFIGURE)) { IOUtils.copy(configFile.getFile(), os); } else { String encoding = configFile.sniffEncoding(); String xml = FileUtils.readFileToString(configFile.getFile(), encoding); Matcher matcher = SECRET_PATTERN.matcher(xml); StringBuffer cleanXml = new StringBuffer(); while (matcher.find()) { if (Secret.decrypt(matcher.group(1)) != null) { matcher.appendReplacement(cleanXml, ">********<"); } } matcher.appendTail(cleanXml); org.apache.commons.io.IOUtils.write(cleanXml.toString(), os, encoding); } }
IOUtils.copy(input, writing(f));
new FilePath(f).symlinkTo(te.getLinkName(), TaskListener.NULL); } else { IOUtils.copy(t, f);
public String invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { File out = new File(f, outputFileName); if (out.exists()) { out.delete(); } IOUtils.copy(is, out); return out.getAbsolutePath(); } });
private void unzip(File dir, InputStream in) throws IOException { File tmpFile = File.createTempFile("tmpzip", null); // uses java.io.tmpdir try { // TODO why does this not simply use ZipInputStream? IOUtils.copy(in, tmpFile); unzip(dir,tmpFile); } finally { tmpFile.delete(); } }
/** * Drains the input stream and closes it. */ public static void drain(InputStream in) throws IOException { copy(in,new NullStream()); in.close(); }
public static void copy(InputStream in, File out) throws IOException { FileOutputStream fos = new FileOutputStream(out); try { copy(in,fos); } finally { closeQuietly(fos); } }
public static void copy(InputStream in, File out) throws IOException { FileOutputStream fos = new FileOutputStream(out); try { copy(in, fos); } finally { closeQuietly(fos); } }
public static void copy(InputStream in, File out) throws IOException { FileOutputStream fos = new FileOutputStream(out); try { copy(in,fos); } finally { closeQuietly(fos); } }
public static void copy(File src, OutputStream out) throws IOException { FileInputStream in = new FileInputStream(src); try { copy(in,out); } finally { closeQuietly(in); } }
public static void copy(File src, OutputStream out) throws IOException { FileInputStream in = new FileInputStream(src); try { copy(in, out); } finally { closeQuietly(in); } }
/** * Drains the input stream and closes it. */ public static void drain(InputStream in) throws IOException { copy(in,new NullStream()); in.close(); }
public static void copy(File src, OutputStream out) throws IOException { FileInputStream in = new FileInputStream(src); try { copy(in,out); } finally { closeQuietly(in); } }
/** * Drains the input stream and closes it. */ public static void drain(InputStream in) throws IOException { copy(in, new NullStream()); in.close(); }
@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://hudson-ci.org/" + path); FileUtils.copyURLToFile(url,cache); } resp.setContentType(getMimeType(path)); IOUtils.copy(cache,resp.getOutputStream()); }
@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://hudson-ci.org/" + path); FileUtils.copyURLToFile(url, cache); } resp.setContentType(getMimeType(path)); IOUtils.copy(cache, resp.getOutputStream()); }
@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://hudson-ci.org/" + path); FileUtils.copyURLToFile(url,cache); } resp.setContentType(getMimeType(path)); IOUtils.copy(cache,resp.getOutputStream()); }
@edu.umd.cs.findbugs.annotations.SuppressWarnings("DM_DEFAULT_ENCODING") public void doIndex(StaplerResponse rsp) throws IOException { Process p = new ProcessBuilder("dot", "-Tpng").start(); writeDot(new PrintWriter(p.getOutputStream())); rsp.setContentType("image/png"); IOUtils.copy(p.getInputStream(), rsp.getOutputStream()); }
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; } }