當前位置: 首頁>>代碼示例>>Java>>正文


Java Flushable類代碼示例

本文整理匯總了Java中java.io.Flushable的典型用法代碼示例。如果您正苦於以下問題:Java Flushable類的具體用法?Java Flushable怎麽用?Java Flushable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Flushable類屬於java.io包,在下文中一共展示了Flushable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: flush

import java.io.Flushable; //導入依賴的package包/類
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();
    }
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:18,代碼來源:SyncRequestProcessor.java

示例2: flush

import java.io.Flushable; //導入依賴的package包/類
@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);
   }
}
 
開發者ID:wellsb1,項目名稱:fort_j,代碼行數:17,代碼來源:Streams.java

示例3: flush

import java.io.Flushable; //導入依賴的package包/類
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());
	}
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:24,代碼來源:MetricCopyExporter.java

示例4: flush

import java.io.Flushable; //導入依賴的package包/類
/**
 * 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.
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:23,代碼來源:Formatter.java

示例5: flush

import java.io.Flushable; //導入依賴的package包/類
/**
  * 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.
     }
 }
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:23,代碼來源:Formatter.java

示例6: flush

import java.io.Flushable; //導入依賴的package包/類
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());
	}
}
 
開發者ID:Nephilim84,項目名稱:contestparser,代碼行數:24,代碼來源:MetricCopyExporter.java

示例7: readLine

import java.io.Flushable; //導入依賴的package包/類
@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;
}
 
開發者ID:y-lan,項目名稱:presto,代碼行數:20,代碼來源:LineReader.java

示例8: handleNotification

import java.io.Flushable; //導入依賴的package包/類
@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();
}
 
開發者ID:jjfiv,項目名稱:chai,代碼行數:26,代碼來源:MemoryNotifier.java

示例9: testFlush

import java.io.Flushable; //導入依賴的package包/類
/**
 * 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));
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:23,代碼來源:StreamHelperTest.java

示例10: test_flush

import java.io.Flushable; //導入依賴的package包/類
/**
 * @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();
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:21,代碼來源:FormatterTest.java

示例11: flush

import java.io.Flushable; //導入依賴的package包/類
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;
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:19,代碼來源:Flushables.java

示例12: testAppendAndFlush

import java.io.Flushable; //導入依賴的package包/類
@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");
}
 
開發者ID:google,項目名稱:closure-templates,代碼行數:25,代碼來源:CountingFlushableAppendableTest.java

示例13: flush

import java.io.Flushable; //導入依賴的package包/類
@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);
		}
	}
}
 
開發者ID:locationtech,項目名稱:geowave,代碼行數:18,代碼來源:DataStoreIndexWriter.java

示例14: AnsiConsole

import java.io.Flushable; //導入依賴的package包/類
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;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:9,代碼來源:AnsiConsole.java

示例15: flushQuietly

import java.io.Flushable; //導入依賴的package包/類
public static void flushQuietly(Flushable flushable) {
    if (flushable == null) return;
    try {
        flushable.flush();
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:IOUtils.java


注:本文中的java.io.Flushable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。