/** * Write an InputStream to a file. */ public static void write(InputStream is, File f) throws IOException { write(is, f, DEFAULT_BUFFER_SIZE); }
/** * Write an File to an OutputStream * Note: this will not close the outputStream; */ public static void write(File f, OutputStream outputStream) throws IOException { write(f, outputStream, DEFAULT_BUFFER_SIZE); }
/** * Write an File to an OutputStream * Note: this will not close the outputStream; */ public static void write(File f, OutputStream outputStream) throws IOException { write(f, outputStream, DEFAULT_BUFFER_SIZE); }
/** * Write an InputStream to a file. */ public static void write(InputStream is, File f) throws IOException { write(is, f, DEFAULT_BUFFER_SIZE); }
/** * Write an InputStream to a file. */ public static void write(InputStream is, String fileName) throws IOException { File f = new File(fileName); write(is,f); }
/** * Write an InputStream to a file. */ public static void write(InputStream is, String fileName) throws IOException { File f = new File(fileName); write(is,f); }
/** * Write an File to an OutputStream * Note: this will not close the outputStream; */ public static void write(File f, OutputStream outputStream, int bufferSize) throws IOException { FileInputStream fis = null; try { fis = new FileInputStream(f); write(fis, outputStream, bufferSize); } finally { if (fis != null) { fis.close(); } } }
/** * Write an File to an OutputStream * Note: this will not close the outputStream; */ public static void write(File f, OutputStream outputStream, int bufferSize) throws IOException { FileInputStream fis = null; try { fis = new FileInputStream(f); write(fis, outputStream, bufferSize); } finally { if (fis != null) { fis.close(); } } }
private void writeEntry(String name, ZipOutputStream out, byte[] contents) throws IOException { ZipEntry e = new ZipEntry(name); out.putNextEntry(e); FileUtils.write(new ByteArrayInputStream(contents), out, 1024); out.closeEntry(); }
private void writeEntry(String name, ZipOutputStream out, byte[] contents) throws IOException { ZipEntry e = new ZipEntry(name); out.putNextEntry(e); FileUtils.write(new ByteArrayInputStream(contents), out, 1024); out.closeEntry(); }
/** * Write a byte array to a file. */ public static void write(byte[] data, String fileName) throws IOException { ByteArrayInputStream bais = null; InputStream is = null; try { bais = new ByteArrayInputStream(data); is = new BufferedInputStream(bais); write(is, fileName); } finally { if (is != null) { is.close(); } if (bais != null) { bais.close(); } } }
/** * Write a byte array to a file. */ public static void write(byte[] data, File file) throws IOException { ByteArrayInputStream bais = null; InputStream is = null; try { bais = new ByteArrayInputStream(data); is = new BufferedInputStream(bais); write(is, file); } finally { if (is != null) { is.close(); } if (bais != null) { bais.close(); } } }
/** * Write a byte array to a file. */ public static void write(byte[] data, String fileName) throws IOException { ByteArrayInputStream bais = null; InputStream is = null; try { bais = new ByteArrayInputStream(data); is = new BufferedInputStream(bais); write(is, fileName); } finally { if (is != null) { is.close(); } if (bais != null) { bais.close(); } } }
/** * Write a byte array to a file. */ public static void write(byte[] data, File file) throws IOException { ByteArrayInputStream bais = null; InputStream is = null; try { bais = new ByteArrayInputStream(data); is = new BufferedInputStream(bais); write(is, file); } finally { if (is != null) { is.close(); } if (bais != null) { bais.close(); } } }
private static void addDirectory(File dir, ZipOutputStream zos, int parentLength) throws IOException { String[] files = dir.list(); for (String entry : files) { File f = new File(dir, entry); if (f.isDirectory()) { addDirectory(f, zos, parentLength); } else { ZipEntry e = new ZipEntry(f.getPath().substring(parentLength)); zos.putNextEntry(e); FileUtils.write(f, zos); zos.closeEntry(); } } }
try { fis = new FileInputStream(fromFile); write(fis, toFileName); } finally { if (fis != null) {
try { fis = new FileInputStream(fromFile); write(fis, toFileName); } finally { if (fis != null) {
int manifestBegin = manifestStr.indexOf("<xmi"); configStr = configStr.substring(0, index) + manifestStr.substring(manifestBegin) + "</VDB>"; FileUtils.write(configStr.getBytes(), config); manifest.delete();
public void testWrite() throws Exception{ File tmp = null; try { tmp = File.createTempFile(TEMP_FILE_PREFFIX, null); final FileInputStream is = new FileInputStream(FILE_NAME); FileUtils.write(is, tmp); if(tmp == null || tmp.length() == 0){ fail("Content not written to new file"); //$NON-NLS-1$ } }finally { if(tmp != null) { tmp.delete(); } } }
public void testWriteEmptyFile() throws Exception{ File tmp = null; File emptyFile = null; try { tmp = File.createTempFile(TEMP_FILE_PREFFIX, null); emptyFile = File.createTempFile("EMPTY", null); //$NON-NLS-1$ final FileInputStream is = new FileInputStream(emptyFile); FileUtils.write(is, tmp); if(tmp == null || tmp.length() > 0){ fail("content available; must be empty"); //$NON-NLS-1$ } }finally { if(tmp != null) { tmp.delete(); } if (emptyFile != null) { emptyFile.delete(); } } }