Java 类java.io.Flushable 实例源码

项目:fuck_zookeeper    文件:SyncRequestProcessor.java   
private void flush(LinkedList<Request> toFlush)
    throws IOException, RequestProcessorException
{
    if (toFlush.isEmpty())
        return;

    zks.getZKDatabase().commit();
    while (!toFlush.isEmpty()) {
        Request i = toFlush.remove();
        if (nextProcessor != null) {
            nextProcessor.processRequest(i);
        }
    }
    if (nextProcessor != null && nextProcessor instanceof Flushable) {
        ((Flushable)nextProcessor).flush();
    }
}
项目:fort_j    文件:Streams.java   
@ApiMethod
@Comment(value = "Simply calls stream.flush() but throws RuntimeException instead of IOException")
public static void flush(Flushable stream)
{
   try
   {
      if (stream != null)
      {
         stream.flush();
      }
   }
   catch (Exception ex)
   {
      Lang.rethrow(ex);
   }
}
项目:https-github.com-apache-zookeeper    文件:SyncRequestProcessor.java   
private void flush(LinkedList<Request> toFlush)
    throws IOException, RequestProcessorException
{
    if (toFlush.isEmpty())
        return;

    zks.getZKDatabase().commit();
    while (!toFlush.isEmpty()) {
        Request i = toFlush.remove();
        if (nextProcessor != null) {
            nextProcessor.processRequest(i);
        }
    }
    if (nextProcessor != null && nextProcessor instanceof Flushable) {
        ((Flushable)nextProcessor).flush();
    }
}
项目:ZooKeeper    文件:SyncRequestProcessor.java   
private void flush(LinkedList<Request> toFlush)
    throws IOException, RequestProcessorException
{
    if (toFlush.isEmpty())
        return;

    zks.getZKDatabase().commit();
    while (!toFlush.isEmpty()) {
        Request i = toFlush.remove();
        if (nextProcessor != null) {
            nextProcessor.processRequest(i);
        }
    }
    if (nextProcessor != null && nextProcessor instanceof Flushable) {
        ((Flushable)nextProcessor).flush();
    }
}
项目:StreamProcessingInfrastructure    文件:SyncRequestProcessor.java   
private void flush(LinkedList<Request> toFlush)
    throws IOException, RequestProcessorException
{
    if (toFlush.isEmpty())
        return;

    zks.getZKDatabase().commit();
    while (!toFlush.isEmpty()) {
        Request i = toFlush.remove();
        if (nextProcessor != null) {
            nextProcessor.processRequest(i);
        }
    }
    if (nextProcessor != null && nextProcessor instanceof Flushable) {
        ((Flushable)nextProcessor).flush();
    }
}
项目:zookeeper    文件:SyncRequestProcessor.java   
private void flush(LinkedList<Request> toFlush)
    throws IOException, RequestProcessorException
{
    if (toFlush.isEmpty())
        return;

    zks.getZKDatabase().commit();
    while (!toFlush.isEmpty()) {
        Request i = toFlush.remove();
        if (nextProcessor != null) {
            nextProcessor.processRequest(i);
        }
    }
    if (nextProcessor != null && nextProcessor instanceof Flushable) {
        ((Flushable)nextProcessor).flush();
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MetricCopyExporter.java   
private void flush(GaugeWriter writer) {
    if (writer instanceof CompositeMetricWriter) {
        for (MetricWriter child : (CompositeMetricWriter) writer) {
            flush(child);
        }
    }
    try {
        if (ClassUtils.isPresent("java.io.Flushable", null)) {
            if (writer instanceof Flushable) {
                ((Flushable) writer).flush();
                return;
            }
        }
        Method method = ReflectionUtils.findMethod(writer.getClass(), "flush");
        if (method != null) {
            ReflectionUtils.invokeMethod(method, writer);
        }
    }
    catch (Exception ex) {
        logger.warn("Could not flush MetricWriter: " + ex.getClass() + ": "
                + ex.getMessage());
    }
}
项目:SecureKeeper    文件:SyncRequestProcessor.java   
private void flush(LinkedList<Request> toFlush)
    throws IOException, RequestProcessorException
{
    if (toFlush.isEmpty())
        return;

    zks.getZKDatabase().commit();
    while (!toFlush.isEmpty()) {
        Request i = toFlush.remove();
        if (nextProcessor != null) {
            nextProcessor.processRequest(i);
        }
    }
    if (nextProcessor != null && nextProcessor instanceof Flushable) {
        ((Flushable)nextProcessor).flush();
    }
}
项目:SecureKeeper    文件:SyncRequestProcessor.java   
private void flush(LinkedList<Request> toFlush)
    throws IOException, RequestProcessorException
{
    if (toFlush.isEmpty())
        return;

    zks.getZKDatabase().commit();
    while (!toFlush.isEmpty()) {
        Request i = toFlush.remove();
        if (nextProcessor != null) {
            nextProcessor.processRequest(i);
        }
    }
    if (nextProcessor != null && nextProcessor instanceof Flushable) {
        ((Flushable)nextProcessor).flush();
    }
}
项目:javify    文件:Formatter.java   
/**
 * Flushes the formatter, writing any cached data to the output
 * stream.  If the underlying output stream supports the
 * {@link Flushable} interface, it is also flushed.
 *
 * @throws FormatterClosedException if the formatter is closed.
 */
public void flush()
{
  if (closed)
    throw new FormatterClosedException();
  try
    {
      if (out instanceof Flushable)
        ((Flushable) out).flush();
    }
  catch (IOException _)
    {
      // FIXME: do we ignore these or do we set ioException?
      // The docs seem to indicate that we should ignore.
    }
}
项目:spring-boot-concourse    文件:MetricCopyExporter.java   
private void flush(GaugeWriter writer) {
    if (writer instanceof CompositeMetricWriter) {
        for (MetricWriter child : (CompositeMetricWriter) writer) {
            flush(child);
        }
    }
    try {
        if (ClassUtils.isPresent("java.io.Flushable", null)) {
            if (writer instanceof Flushable) {
                ((Flushable) writer).flush();
                return;
            }
        }
        Method method = ReflectionUtils.findMethod(writer.getClass(), "flush");
        if (method != null) {
            ReflectionUtils.invokeMethod(method, writer);
        }
    }
    catch (Exception ex) {
        logger.warn("Could not flush MetricWriter: " + ex.getClass() + ": "
                + ex.getMessage());
    }
}
项目:jvm-stm    文件:Formatter.java   
/**
  * Flushes the formatter, writing any cached data to the output
  * stream.  If the underlying output stream supports the
  * {@link Flushable} interface, it is also flushed.
  *
  * @throws FormatterClosedException if the formatter is closed.
  */
 public void flush()
 {
   if (closed)
     throw new FormatterClosedException();
   try
     {
if (out instanceof Flushable)
  ((Flushable) out).flush();
     }
   catch (IOException _)
     {
// FIXME: do we ignore these or do we set ioException?
// The docs seem to indicate that we should ignore.
     }
 }
项目:contestparser    文件:MetricCopyExporter.java   
private void flush(MetricWriter writer) {
    if (writer instanceof CompositeMetricWriter) {
        for (MetricWriter child : (CompositeMetricWriter) writer) {
            flush(child);
        }
    }
    try {
        if (ClassUtils.isPresent("java.io.Flushable", null)) {
            if (writer instanceof Flushable) {
                ((Flushable) writer).flush();
                return;
            }
        }
        Method method = ReflectionUtils.findMethod(writer.getClass(), "flush");
        if (method != null) {
            ReflectionUtils.invokeMethod(method, writer);
        }
    }
    catch (Exception ex) {
        logger.warn("Could not flush MetricWriter: " + ex.getClass() + ": "
                + ex.getMessage());
    }
}
项目:StreamBench    文件:SyncRequestProcessor.java   
private void flush(LinkedList<Request> toFlush)
    throws IOException, RequestProcessorException
{
    if (toFlush.isEmpty())
        return;

    zks.getZKDatabase().commit();
    while (!toFlush.isEmpty()) {
        Request i = toFlush.remove();
        if (nextProcessor != null) {
            nextProcessor.processRequest(i);
        }
    }
    if (nextProcessor != null && nextProcessor instanceof Flushable) {
        ((Flushable)nextProcessor).flush();
    }
}
项目:presto    文件:LineReader.java   
@Override
public String readLine(String prompt, Character mask)
        throws IOException
{
    String line;
    interrupted = false;
    try {
        line = super.readLine(prompt, mask);
    }
    catch (UserInterruptException e) {
        interrupted = true;
        return null;
    }

    if (getHistory() instanceof Flushable) {
        ((Flushable) getHistory()).flush();
    }
    return line;
}
项目:chai    文件:MemoryNotifier.java   
@Override
public void handleNotification(Notification notification, Object handback) {
  if(!notification.getType().equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) return;
  logger.info("MemoryNotifier::activate");

  //--- copy the list of listener's  in a thread-safe way; doesn't matter if we get an update while we're notifying this way.
  final List<Flushable> toNotify = new ArrayList<>();
  synchronized (instance) {
    toNotify.addAll(listeners);
  }

  //--- spawn a thread to handle flushing; don't do multiple because threads can be heavy on the memory usage.
  Thread deferred = new Thread() {
    public void run() {
      for (final Flushable flushable : toNotify) {
        try {
          flushable.flush();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  };
  deferred.start();
}
项目:ph-commons    文件:StreamHelperTest.java   
/**
 * Test method flush
 */
@Test
public void testFlush ()
{
  // flush null stream
  assertFalse (StreamHelper.flush ((Flushable) null).isSuccess ());

  // flush stream with exception
  assertFalse (StreamHelper.flush (new MockThrowingFlushable ()).isSuccess ());

  // flush without exception
  assertTrue (StreamHelper.flush (new MockFlushable ()).isSuccess ());

  final MockCloseableWithState c = new MockCloseableWithState ();
  assertTrue (StreamHelper.flush (c).isSuccess ());
  assertFalse (c.isClosed ());
  assertTrue (c.isFlushed ());

  StreamHelper.close (new FilterOutputStream (null));
}
项目:cn1    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#flush()
 */
public void test_flush() throws IOException {
    Formatter f = null;
    f = new Formatter(notExist);
    assertTrue(f instanceof Flushable);
    f.close();
    try {
        f.flush();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }

    f = new Formatter();
    // For destination that does not implement Flushable
    // No exception should be thrown
    f.flush();
}
项目:JamVM-PH    文件:Formatter.java   
/**
  * Flushes the formatter, writing any cached data to the output
  * stream.  If the underlying output stream supports the
  * {@link Flushable} interface, it is also flushed.
  *
  * @throws FormatterClosedException if the formatter is closed.
  */
 public void flush()
 {
   if (closed)
     throw new FormatterClosedException();
   try
     {
if (out instanceof Flushable)
  ((Flushable) out).flush();
     }
   catch (IOException _)
     {
// FIXME: do we ignore these or do we set ioException?
// The docs seem to indicate that we should ignore.
     }
 }
项目:12306-android-Decompile    文件:Flushables.java   
public static void flush(Flushable paramFlushable, boolean paramBoolean)
  throws IOException
{
  try
  {
    paramFlushable.flush();
    return;
  }
  catch (IOException localIOException)
  {
    if (paramBoolean)
    {
      logger.log(Level.WARNING, "IOException thrown while flushing Flushable.", localIOException);
      return;
    }
  }
  throw localIOException;
}
项目:closure-templates    文件:CountingFlushableAppendableTest.java   
@Test
public void testAppendAndFlush() throws Exception {
  final StringBuilder progress = new StringBuilder();
  Flushable flushable =
      new Flushable() {
        @Override
        public void flush() {
          progress.append("F");
        }
      };

  CountingFlushableAppendable c = new CountingFlushableAppendable(progress, flushable);
  assertThat(c.getAppendedCountSinceLastFlush()).isEqualTo(0);
  c.append("12");
  assertThat(c.getAppendedCountSinceLastFlush()).isEqualTo(2);
  c.append("3");
  assertThat(c.getAppendedCountSinceLastFlush()).isEqualTo(3);
  c.flush();
  assertThat(c.getAppendedCountSinceLastFlush()).isEqualTo(0);
  c.append('c');
  assertThat(c.getAppendedCountSinceLastFlush()).isEqualTo(1);
  c.append("123", 1, 2);
  assertThat(progress.toString()).isEqualTo("123Fc2");
}
项目:geowave    文件:DataStoreIndexWriter.java   
@Override
public synchronized void flush() {
    // thread safe flush of the writers
    if (writer != null) {
        writer.flush();
    }
    if (this.callback instanceof Flushable) {
        try {
            ((Flushable) callback).flush();
        }
        catch (final IOException e) {
            LOGGER.error(
                    "Cannot flush callbacks",
                    e);
        }
    }
}
项目:classpath    文件:Formatter.java   
/**
 * Flushes the formatter, writing any cached data to the output
 * stream.  If the underlying output stream supports the
 * {@link Flushable} interface, it is also flushed.
 *
 * @throws FormatterClosedException if the formatter is closed.
 */
public void flush()
{
  if (closed)
    throw new FormatterClosedException();
  try
    {
      if (out instanceof Flushable)
        ((Flushable) out).flush();
    }
  catch (IOException _)
    {
      // FIXME: do we ignore these or do we set ioException?
      // The docs seem to indicate that we should ignore.
    }
}
项目:freeVM    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#flush()
 */
public void test_flush() throws IOException {
    Formatter f = null;
    f = new Formatter(notExist);
    assertTrue(f instanceof Flushable);
    f.close();
    try {
        f.flush();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }

    f = new Formatter();
    // For destination that does not implement Flushable
    // No exception should be thrown
    f.flush();
}
项目:freeVM    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#flush()
 */
public void test_flush() throws IOException {
    Formatter f = null;
    f = new Formatter(notExist);
    assertTrue(f instanceof Flushable);
    f.close();
    try {
        f.flush();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }

    f = new Formatter();
    // For destination that does not implement Flushable
    // No exception should be thrown
    f.flush();
}
项目:12306-android-Decompile    文件:Flushables.java   
public static void flush(Flushable paramFlushable, boolean paramBoolean)
  throws IOException
{
  try
  {
    paramFlushable.flush();
    return;
  }
  catch (IOException localIOException)
  {
    if (paramBoolean)
    {
      logger.log(Level.WARNING, "IOException thrown while flushing Flushable.", localIOException);
      return;
    }
  }
  throw localIOException;
}
项目:Reer    文件:AnsiConsole.java   
public AnsiConsole(Appendable target, Flushable flushable, ColorMap colorMap, boolean forceAnsi) {
    this.target = target;
    this.flushable = flushable;
    this.colorMap = colorMap;
    textArea = new TextAreaImpl(textCursor);
    statusBar = new LabelImpl(statusBarCursor);
    this.forceAnsi = forceAnsi;
}
项目:GitHub    文件:IOUtils.java   
public static void flushQuietly(Flushable flushable) {
    if (flushable == null) return;
    try {
        flushable.flush();
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    }
}
项目:EvolvingNetLib    文件:CCIOUtils.java   
public static void flushQuietly(Flushable flushable) {
    if (flushable == null) return;
    try {
        flushable.flush();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:easyfilemanager    文件:IoUtils.java   
/**
 * Closes 'closeable', ignoring any checked exceptions. Does nothing if 'closeable' is null.
 */
public static void flushQuietly(Flushable flushable) {
    if (flushable != null) {
        try {
            flushable.flush();
        } catch (RuntimeException rethrown) {
            throw rethrown;
        } catch (Exception ignored) {
        }
    }
}
项目:guava-mock    文件:Flushables.java   
/**
 * Equivalent to calling {@code flush(flushable, true)}, but with no {@code IOException} in the
 * signature.
 *
 * @param flushable the {@code Flushable} object to be flushed.
 */
public static void flushQuietly(Flushable flushable) {
  try {
    flush(flushable, true);
  } catch (IOException e) {
    logger.log(Level.SEVERE, "IOException should not have been thrown.", e);
  }
}
项目:guava-mock    文件:AppendableWriter.java   
@Override
public void flush() throws IOException {
  checkNotClosed();
  if (target instanceof Flushable) {
    ((Flushable) target).flush();
  }
}
项目:guava-mock    文件:FlushablesTest.java   
private void setupFlushable(boolean shouldThrowOnFlush) throws IOException {
  mockFlushable = mock(Flushable.class);
  if (shouldThrowOnFlush) {
    doThrow(new IOException("This should only appear in the "
        + "logs. It should not be rethrown.")).when(mockFlushable).flush();
  }
}
项目:guava-mock    文件:FlushablesTest.java   
private void doFlush(Flushable flushable, boolean swallowException,
    boolean expectThrown) throws IOException {
  try {
    Flushables.flush(flushable, swallowException);
    if (expectThrown) {
      fail("Didn't throw exception.");
    }
  } catch (IOException e) {
    if (!expectThrown) {
      fail("Threw exception");
    }
  }
  verify(flushable).flush();
}
项目:letv    文件:HttpRequest.java   
protected void done() throws IOException {
    if (this.closeable instanceof Flushable) {
        ((Flushable) this.closeable).flush();
    }
    if (this.ignoreCloseExceptions) {
        try {
            this.closeable.close();
            return;
        } catch (IOException e) {
            return;
        }
    }
    this.closeable.close();
}
项目:letv    文件:CommonUtils.java   
public static void flushOrLog(Flushable f, String message) {
    if (f != null) {
        try {
            f.flush();
        } catch (IOException e) {
            Fabric.getLogger().e(Fabric.TAG, message, e);
        }
    }
}
项目:BWS-Android    文件:HttpRequest.java   
@Override
protected void done() throws IOException {
    if (closeable instanceof Flushable)
        ((Flushable) closeable).flush();
    if (ignoreCloseExceptions)
        try {
            closeable.close();
        } catch (IOException e) {
            // Ignored
        }
    else
        closeable.close();
}
项目:whackpad    文件:LenientFormatter.java   
/**
 * Flushes the {@code Formatter}. If the output destination is {@link Flushable},
 * then the method {@code flush()} will be called on that destination.
 * 
 * @throws FormatterClosedException
 *             if the {@code Formatter} has been closed.
 */
public void flush() {
    checkClosed();
    if (out instanceof Flushable) {
        try {
            ((Flushable) out).flush();
        } catch (IOException e) {
            lastIOException = e;
        }
    }
}
项目:NiuBi    文件:HttpRequest.java   
@Override
protected void done() throws IOException {
  if (closeable instanceof Flushable)
    ((Flushable) closeable).flush();
  if (ignoreCloseExceptions)
    try {
      closeable.close();
    } catch (IOException e) {
      // Ignored
    }
  else
    closeable.close();
}
项目:apfloat    文件:FormattingHelper.java   
@Override
public void flush()
    throws IOException
{
    if (this.out instanceof Flushable)
    {
        ((Flushable) this.out).flush();
    }
}