Example usage for java.io Flushable flush

List of usage examples for java.io Flushable flush

Introduction

In this page you can find the example usage for java.io Flushable flush.

Prototype

void flush() throws IOException;

Source Link

Document

Flushes this stream by writing any buffered output to the underlying stream.

Usage

From source file:Main.java

public static void flushAll(Flushable... flushes) {
    if (flushes.length <= 0)
        return;/* w w w.  ja va  2  s  . co  m*/

    for (Flushable flush : flushes) {
        if (flush == null)
            continue;
        try {
            flush.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:edu.umn.msi.tropix.common.io.IOUtilsImpl.java

public void flush(final Flushable flushable) {
    try {/* www .j av a 2 s  . c o m*/
        flushable.flush();
    } catch (final IOException e) {
        throw new IORuntimeException(e);
    }
}

From source file:edu.umn.msi.tropix.common.io.IOUtilsImpl.java

public void flushQuietly(@Nullable final Flushable flushable) {
    try {//w w w. j ava  2  s . c o  m
        if (flushable != null) {
            flushable.flush();
        }
    } catch (final Exception e) {
        // Ignore.
        return;
    }
}

From source file:edu.umn.msi.tropix.common.io.IOUtilsTest.java

@Test(groups = "unit")
public void flush() throws IOException {
    final Flushable flushable = EasyMock.createMock(Flushable.class);
    flushable.flush();
    EasyMock.replay(flushable);// w  ww .  j  a v  a  2  s. com
    ioUtils.flush(flushable);
    EasyMock.verify(flushable);
}

From source file:edu.umn.msi.tropix.common.io.IOUtilsTest.java

@Test(groups = "unit", expectedExceptions = IORuntimeException.class)
public void flushException() throws IOException {
    final Flushable flushable = EasyMock.createMock(Flushable.class);
    flushable.flush();
    EasyMock.expectLastCall().andThrow(new IOException());
    EasyMock.replay(flushable);/* w w  w  .j av a  2  s . c o  m*/
    ioUtils.flush(flushable);
}

From source file:edu.umn.msi.tropix.common.io.IOUtilsTest.java

@Test(groups = "unit")
public void flushQuietly() throws IOException {
    final Flushable flushable = EasyMock.createMock(Flushable.class);
    flushable.flush();
    EasyMock.replay(flushable);//ww w  .  j  a v a 2  s. c  om
    ioUtils.flushQuietly(flushable);
    EasyMock.verify(flushable);
}

From source file:edu.umn.msi.tropix.common.io.IOUtilsTest.java

@Test(groups = "unit")
public void flushQuietlyException() throws IOException {
    final Flushable flushable = EasyMock.createMock(Flushable.class);
    flushable.flush();
    EasyMock.expectLastCall().andThrow(new IOException());
    EasyMock.replay(flushable);/*from  ww w.  j ava 2  s.co  m*/
    ioUtils.flushQuietly(flushable);
    ioUtils.flushQuietly(null);
}

From source file:org.apache.streams.s3.S3PersistWriter.java

private void safeFlush(Flushable flushable) {
    // This is wrapped with a ByteArrayOutputStream, so this is really safe.
    if (flushable != null) {
        try {/*from  ww  w .j a  v  a  2  s.  c  om*/
            flushable.flush();
        } catch (IOException ex) {
            LOGGER.trace("safeFlush", ex);
        }
    }
}

From source file:org.limewire.util.FileUtils.java

/**
 * A utility method to flush Flushable objects (Readers, Writers, 
 * Input- and OutputStreams and RandomAccessFiles).
 *///www  .  ja v  a2 s  .c om
public static void flush(Flushable flushable) {
    if (flushable != null) {
        try {
            flushable.flush();
        } catch (IOException ignored) {
        }
    }
}