/** * Reads the data from the Input stream and writes to the output stream * Buffers each stream. Terminates when a read from the Input stream results * in EOF */ public void copy(InputStream from, OutputStream to) throws IOException { copy(from, to, true, false); }
/** * Reads the data from the Input stream and writes to the output stream * Buffers each stream. Terminates when a read from the Input stream results * in EOF */ public void copy(InputStream from, OutputStream to) throws IOException { copy(from, to, true, false); }
/** * Reads the data from the Input stream and writes to the output stream * Buffers each stream. Terminates when a read from the Input stream results * in EOF */ public void copy(InputStream from, OutputStream to) throws IOException { copy(from, to, true, false); }
/** reads the entire contents of stream into a String */ public String readString(InputStream from) throws IOException { ByteArrayOutputStream buf = new ByteArrayOutputStream(); try { copy(from, buf); return buf.toString(); } finally { buf.close(); } }
/** reads the entire contents of stream into a String */ public String readString(InputStream from) throws IOException { ByteArrayOutputStream buf = new ByteArrayOutputStream(); try { copy(from, buf); return buf.toString(); } finally { buf.close(); } }
/** reads the entire contents of stream into a String */ public String readString(InputStream from) throws IOException { ByteArrayOutputStream buf = new ByteArrayOutputStream(); try { copy(from, buf); return buf.toString(); } finally { buf.close(); } }
@Override public void inner() throws Exception { new Streams().copy(from, to, false, true); } }.exec();
public void inner() throws Exception { new Streams().copy(from, to, false, true); } }.exec();
public void inner() throws Exception { InputStream is = getResourceAsStream(resourceName); try { FileOutputStream fos = new FileOutputStream(file); try { copy(is, fos); } finally { fos.close(); } } finally { is.close(); } } };
public void inner() throws Exception { new Streams().copy(from, to, false, true); } }.exec();
@Override public void inner() throws Exception { InputStream is = getResourceAsStream(resourceName); try { FileOutputStream fos = new FileOutputStream(file); try { copy(is, fos); } finally { fos.close(); } } finally { is.close(); } } };
public void inner() throws Exception { InputStream is = getResourceAsStream(resourceName); try { FileOutputStream fos = new FileOutputStream(file); try { copy(is, fos); } finally { fos.close(); } } finally { is.close(); } } };
private void expandEachEntry(File outputDir, JarInputStream jis) throws IOException, FileNotFoundException { JarEntry entry = jis.getNextJarEntry(); while (entry != null) { File file = new File(outputDir, entry.getName()); if (!file.exists()) { if (entry.isDirectory()) { file.mkdirs(); } else { File parent = file.getParentFile(); parent.mkdirs(); FileOutputStream fos = new FileOutputStream(file); try { copy(jis, fos); } finally { fos.close(); } } } entry = jis.getNextJarEntry(); } } }
private void expandEachEntry(File outputDir, JarInputStream jis) throws IOException, FileNotFoundException { while (true) { JarEntry entry = jis.getNextJarEntry(); if (entry == null) { break; } File file = new File(outputDir, entry.getName()); if (!file.exists()) { if (entry.isDirectory()) { file.mkdirs(); } else { File parent = file.getParentFile(); parent.mkdirs(); FileOutputStream fos = new FileOutputStream(file); try { copy(jis, fos); } finally { fos.close(); } } } } }
public void testStreamsCopyErrorSilent() throws Exception { ThrowingInputStream from = new ThrowingInputStream(); ByteArrayOutputStream to = new ByteArrayOutputStream(); boolean isBuffered = false; boolean terminateOnFalure = true; // close quitely if "terminateOnFalure = true" new Streams().copy(from, to, isBuffered, terminateOnFalure); assertEquals(from.data(), new String(to.toByteArray())); }
public void testStreamsCopyErrorSilent() throws Exception { ThrowingInputStream from = new ThrowingInputStream(); ByteArrayOutputStream to = new ByteArrayOutputStream(); boolean isBuffered = false; boolean terminateOnFalure = true; // close quitely if "terminateOnFalure = true" new Streams().copy(from, to, isBuffered, terminateOnFalure); assertEquals(from.data(), new String(to.toByteArray())); }
public void testStreamsCopyErrorSilent() throws Exception { ThrowingInputStream from = new ThrowingInputStream(); ByteArrayOutputStream to = new ByteArrayOutputStream(); boolean isBuffered = false; boolean terminateOnFalure = true; // close quitely if "terminateOnFalure = true" new Streams().copy(from, to, isBuffered, terminateOnFalure); assertEquals(from.data(), new String(to.toByteArray())); }
private void checkCopyError(boolean isIOException) throws Exception { ThrowingInputStream from = new ThrowingInputStream(); from.ioexception = isIOException; ByteArrayOutputStream to = new ByteArrayOutputStream(); boolean isBuffered = false; boolean terminateOnFalure = false; // throw exception if "terminateOnFalure = false" Exception expected = null; try { new Streams().copy(from, to, isBuffered, terminateOnFalure); } catch (Exception e) { expected = e; } assertNotNull(expected); assertEquals(EXCEPTION_MSG, expected.getMessage()); assertEquals(from.data(), new String(to.toByteArray())); }
private void checkCopyError(boolean isIOException) throws Exception { ThrowingInputStream from = new ThrowingInputStream(); from.ioexception = isIOException; ByteArrayOutputStream to = new ByteArrayOutputStream(); boolean isBuffered = false; boolean terminateOnFalure = false; // throw exception if "terminateOnFalure = false" Exception expected = null; try { new Streams().copy(from, to, isBuffered, terminateOnFalure); } catch (Exception e) { expected = e; } assertNotNull(expected); assertEquals(EXCEPTION_MSG, expected.getMessage()); assertEquals(from.data(), new String(to.toByteArray())); }
private void checkCopyError(boolean isIOException) throws Exception { ThrowingInputStream from = new ThrowingInputStream(); from.ioexception = isIOException; ByteArrayOutputStream to = new ByteArrayOutputStream(); boolean isBuffered = false; boolean terminateOnFalure = false; // throw exception if "terminateOnFalure = false" Exception expected = null; try { new Streams().copy(from, to, isBuffered, terminateOnFalure); } catch (Exception e) { expected = e; } assertNotNull(expected); assertEquals(EXCEPTION_MSG, expected.getMessage()); assertEquals(from.data(), new String(to.toByteArray())); }