@Test public void testReporting() throws IOException { final LinkedList<Double> fractions = new LinkedList<Double>(); fractions.add(0.25); fractions.add(0.75); fractions.add(0.80); fractions.add(1.0); handler.async(4); IndicatingOutputStream ios = new IndicatingOutputStream(file, 20, new ProgressIndicatorBase() { @Override public void setFraction(final double fraction) { handler.done(new Runnable() { @Override public void run() { Assert.assertEquals(fractions.removeFirst(), (Double) fraction); } }); } }); byte[] buf0 = "1234\n".getBytes(); byte[] buf1 = "123456789\n".getBytes(); byte[] buf2 = "678\n".getBytes(); ios.write(buf0); ios.write(buf1); ios.write('5'); ios.write(buf2); ios.close(); Assert.assertEquals("1234\n123456789\n5678\n", FileUtils.readFileToString(file)); }
public void write(int i) throws IOException { cancel(); super.write(i); for(OutputStream observer: observers) { observer.write(i); } report(1); }
IndicatingOutputStream extends FileOutputStream { public void write(int i) throws IOException { cancel(); super.write(i); for(OutputStream observer: observers) { observer.write(i); } report(1); } }
IndicatingOutputStream extends FileOutputStream { public void write(int i) throws IOException { cancel(); super.write(i); for(OutputStream observer: observers) { observer.write(i); } report(1); } IndicatingOutputStream(File file, int size, ProgressIndicator indicator); }
IndicatingOutputStream extends FileOutputStream { public void write(int i) throws IOException { cancel(); super.write(i); for(OutputStream observer: observers) { observer.write(i); } report(1); } IndicatingOutputStream(File file, int size, ProgressIndicator indicator); void addObserver(OutputStream observer); void write(int i); void write(byte[] bytes); void write(byte[] bytes, int off, int len); }
IndicatingOutputStream extends FileOutputStream { public void write(int i) throws IOException { cancel(); super.write(i); for(OutputStream observer: observers) { observer.write(i); } report(1); } IndicatingOutputStream(File file, int size, ProgressIndicator indicator); void addObserver(OutputStream observer); void write(int i); void write(byte[] bytes); void write(byte[] bytes, int off, int len);  }