List of usage examples for java.io BufferedOutputStream BufferedOutputStream
public BufferedOutputStream(OutputStream out)
From source file:edu.dfci.cccb.mev.deseq.domain.simple.FileBackedDESeq.java
@SneakyThrows public static FileBackedDESeq from(InputStream results) { FileBackedDESeq result = new FileBackedDESeq(new TemporaryFolder()); try (OutputStream full = new BufferedOutputStream(new FileOutputStream(result.full)); BufferedInputStream in = new BufferedInputStream(results)) { IOUtils.copy(in, full);//from w w w . j av a2 s . c o m } return result; }
From source file:com.qwazr.utils.IOUtils.java
public static final int copy(InputStream inputStream, File destFile) throws IOException { FileOutputStream fos = new FileOutputStream(destFile); try {//from w w w . j a va 2 s. c o m BufferedOutputStream bos = new BufferedOutputStream(fos); try { return copy(inputStream, fos); } finally { close(bos); } } finally { close(fos); } }
From source file:org.crazydog.util.spring.FileCopyUtils.java
/** * Copy the contents of the given input File to the given output File. * @param in the file to copy from//from w w w . j a va2 s. c o m * @param out the file to copy to * @return the number of bytes copied * @throws IOException in case of I/O errors */ public static int copy(File in, File out) throws IOException { org.springframework.util.Assert.notNull(in, "No input File specified"); org.springframework.util.Assert.notNull(out, "No output File specified"); return copy(new BufferedInputStream(new FileInputStream(in)), new BufferedOutputStream(new FileOutputStream(out))); }
From source file:de.atomfrede.tools.evalutation.tools.plot.util.PlotUtil.java
/** * Saves the given chart as a pdf file with the given file name. * //from w w w . jav a 2 s . c o m * @param file * @param chart * @param width * @param height * @param mapper * @throws IOException */ public static void saveChartAsPDF(File file, JFreeChart chart, int width, int height, FontMapper mapper) throws IOException { OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); writeChartAsPDF(out, chart, width, height, mapper); out.close(); }
From source file:ca.simplegames.micro.utils.IO.java
/** * Copy the contents of the given input File to the given output File. * * @param in the file to copy from/* ww w.j a va 2 s . c o m*/ * @param out the file to copy to * @return the number of bytes copied * @throws java.io.IOException in case of I/O errors */ public static long copy(File in, File out) throws IOException { return copy(new BufferedInputStream(new FileInputStream(in)), new BufferedOutputStream(new FileOutputStream(out))); }
From source file:FileCopyUtils.java
/** * Copy the contents of the given input File to the given output File. * @param in the file to copy from// ww w. j a v a 2 s . c o m * @param out the file to copy to * @return the number of bytes copied * @throws IOException in case of I/O errors */ public static int copy(File in, File out) throws IOException { return copy(new BufferedInputStream(new FileInputStream(in)), new BufferedOutputStream(new FileOutputStream(out))); }
From source file:net.firejack.platform.core.utils.ArchiveUtils.java
/** * @param basePath/* w w w . j a va 2s . c o m*/ * @param zipPath * @param filePaths * @throws java.io.IOException */ public static void zip(File basePath, File zipPath, Map<String, String> filePaths) throws IOException { BufferedInputStream origin = null; ZipOutputStream out = null; FileOutputStream dest = null; try { dest = new FileOutputStream(zipPath); out = new ZipOutputStream(new BufferedOutputStream(dest)); //out.setMethod(ZipOutputStream.DEFLATED); byte data[] = new byte[BUFFER]; for (Map.Entry<String, String> file : filePaths.entrySet()) { String filename = file.getKey(); String filePath = file.getValue(); System.out.println("Adding: " + basePath.getPath() + filePath + " => " + filename); File f = new File(basePath, filePath); if (f.exists()) { FileInputStream fi = new FileInputStream(f); origin = new BufferedInputStream(fi, BUFFER); ZipEntry entry = new ZipEntry(filename); entry.setCrc(FileUtils.checksumCRC32(new File(basePath, filePath))); out.putNextEntry(entry); int count; while ((count = origin.read(data, 0, BUFFER)) != -1) { out.write(data, 0, count); } origin.close(); } } } finally { if (origin != null) origin.close(); if (out != null) out.close(); if (dest != null) dest.close(); } }
From source file:jodtemplate.io.ZipWriter.java
public void zipResources(final Resources resources, final OutputStream output) throws IOException { try (final ZipOutputStream zos = new ZipOutputStream(output); final BufferedOutputStream bos = new BufferedOutputStream(zos)) { for (Resource resource : resources.getResources()) { zos.putNextEntry(new ZipEntry(resource.getName())); try (final InputStream is = resource.getInputStream()) { zos.write(IOUtils.toByteArray(is)); }//from w w w . j a v a 2s.c o m zos.closeEntry(); } } }
From source file:com.manning.androidhacks.hack037.MediaUtils.java
public static void saveRaw(Context context, int raw, String path) { File completePath = new File(Environment.getExternalStorageDirectory(), path); try {/* ww w .java 2s.com*/ completePath.getParentFile().mkdirs(); completePath.createNewFile(); BufferedOutputStream bos = new BufferedOutputStream((new FileOutputStream(completePath))); BufferedInputStream bis = new BufferedInputStream(context.getResources().openRawResource(raw)); byte[] buff = new byte[32 * 1024]; int len; while ((len = bis.read(buff)) > 0) { bos.write(buff, 0, len); } bos.flush(); bos.close(); } catch (IOException io) { Log.e(TAG, "Error: " + io); } }
From source file:Utils.java
/** * Unpack a zip file/*from w ww . j a v a 2s . c o m*/ * * @param theFile * @param targetDir * @return the file * @throws IOException */ public static File unpackArchive(File theFile, File targetDir) throws IOException { if (!theFile.exists()) { throw new IOException(theFile.getAbsolutePath() + " does not exist"); } if (!buildDirectory(targetDir)) { throw new IOException("Could not create directory: " + targetDir); } ZipFile zipFile = new ZipFile(theFile); for (Enumeration entries = zipFile.entries(); entries.hasMoreElements();) { ZipEntry entry = (ZipEntry) entries.nextElement(); File file = new File(targetDir, File.separator + entry.getName()); if (!buildDirectory(file.getParentFile())) { throw new IOException("Could not create directory: " + file.getParentFile()); } if (!entry.isDirectory()) { copyInputStream(zipFile.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(file))); } else { if (!buildDirectory(file)) { throw new IOException("Could not create directory: " + file); } } } zipFile.close(); return theFile; }