Java 8 Flushable - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Flushable class.

This code example shows how to use the following methods:flush
    } 
 
    protected void flush() throws IOException { 
        if (out instanceof Flushable) {
            Flushable flushable = (Flushable) out;
            flushable.flush();
        } 
    } 
 
    protected void panic(IOException exception) {
        // If we can't log, be rude! 
        exception.printStackTrace();
    } 
 
    protected Appendable formatLogEntry(Appendable out, HttpRequest request, String action, String data) throws IOException {
        long cumulativeTimeOfRequest = cumulativeTimeOfRequest(request);
        Date now = new Date();
        formatValue(out, now);
        formatValue(out, now.getTime());
        formatValue(out, cumulativeTimeOfRequest);
6
CodeRank
This code example shows how to use the following methods:flush
    } 
 
    protected void flush() throws IOException {
        if (out instanceof Flushable) {
            Flushable flushable = (Flushable) out;
            flushable.flush();
        } 
    } 
 
    protected void panic(IOException exception) {
        // If we can't log, be rude! 
        exception.printStackTrace();
    } 
 
    protected Appendable formatLogEntry(Appendable out, HttpRequest request, String action, String data) throws IOException {
        long cumulativeTimeOfRequest = cumulativeTimeOfRequest(request);
        Date now = new Date();
        formatValue(out, now);
        formatValue(out, now.getTime());
        formatValue(out, cumulativeTimeOfRequest);
5
CodeRank
This code example shows how to use the following methods:flush
   * @see Closeables#close 
   */ 
  public static void flush(Flushable flushable, boolean swallowIOException)
      throws IOException {
    try { 
      flushable.flush();
    } catch (IOException e) {
      if (swallowIOException) {
        logger.log(Level.WARNING,
            "IOException thrown while flushing Flushable.", e);
      } else { 
        throw e;
      } 
    } 
  } 
 
  /** 
   * Equivalent to calling {@code flush(flushable, true)}, but with no 
   * {@code IOException} in the signature. 
   * 
5
CodeRank
This code example shows how to use the following methods:flush
   * @see Closeables#close 
   */ 
  public static void flush(Flushable flushable, boolean swallowIOException)
      throws IOException { 
    try { 
      flushable.flush();
    } catch (IOException e) {
      logger.log(Level.WARNING,
          "IOException thrown while flushing Flushable.", e);
      if (!swallowIOException) {
        throw e;
      } 
    } 
  } 
 
  /** 
   * Equivalent to calling {@code flush(flushable, true)}, but with no 
   * {@code IOException} in the signature. 
   * 
   * @param flushable the {@code Flushable} object to be flushed. 
5
CodeRank
This code example shows how to use the following methods:flush
	} 
 
	public static void safeFlush(Flushable fa) {
		if (null != fa)
			try { 
				fa.flush();
			} 
			catch (IOException e) {}
	} 
 
	/** 
	 * 为一个输入流包裹一个缓冲流。如果这个输入流本身就是缓冲流,则直接返回 
	 *  
	 * @param ins 
	 *            输入流。 
	 * @return 缓冲输入流 
	 */ 
	public static BufferedInputStream buff(InputStream ins) {
		if (ins instanceof BufferedInputStream)
			return (BufferedInputStream) ins;
3
CodeRank
This code example shows how to use the following methods:flush
 
  // Set up a flushable to expect to be flushed and closed, and optionally to 
  // throw an exception. 
  private void setupFlushable(boolean shouldThrowOnFlush) throws IOException {
    reset(mockFlushable);
    mockFlushable.flush();
    if (shouldThrowOnFlush) {
      expectThrown(); 
    } 
    replay(mockFlushable);
  } 
 
  private void doClose(Closeable closeable, boolean swallowException) {
    doClose(closeable, swallowException, !swallowException);
  } 
 
  // Close the closeable using the Closeables, passing in the swallowException 
  // parameter. expectThrown determines whether we expect an exception to 
  // be thrown by Closeables.close; 
  private void doClose(Closeable closeable, boolean swallowException,
4
CodeRank
This code example shows how to use the following methods:flush
  private static void flushFlushable(Flushable f) {
    if (f == null) {
      return; 
    } 
    try { 
      f.flush();
    } catch (Exception e) {
      logger.log(Level.WARNING, "Error occurred while flushing " + f, e);
    } 
  } 
 
  private Flushables() { 
  } 
} 
5
CodeRank
This code example shows how to use the following methods:flush
	} 
 
	public static void safeFlush(Flushable fa) {
		if (null != fa)
			try { 
				fa.flush();
			} 
			catch (IOException e) {}
	} 
 
	/** 
	 * 为一个输入流包裹一个缓冲流。如果这个输入流本身就是缓冲流,则直接返回 
	 *  
	 * @param ins 
	 *            输入流。 
	 * @return 缓冲输入流 
	 */ 
	public static BufferedInputStream buff(InputStream ins) {
		if (ins instanceof BufferedInputStream)
			return (BufferedInputStream) ins;
3
CodeRank
This code example shows how to use the following methods:flush
		{ 
			return; 
		} 
		try 
		{ 
			aFlushable.flush();
		} catch (final IOException e)
		{ 
			Log.w(LOG_TAG, "Failed to flush.", e);
		} 
	} 
 
 
	/** 
	 * Create and return the cache directory. 
	 *  
	 * @return directory used for caching images 
	 * @throws IOException 
	 */ 
	public static File createAndGetDirectory(@NotEmpty final String directoryName) throws IOException
2
CodeRank
This code example shows how to use the following methods:flush
 
  // Set up a flushable to expect to be flushed and closed, and optionally to 
  // throw an exception. 
  private void setupFlushable(boolean shouldThrowOnFlush) throws IOException {
    reset(mockFlushable);
    mockFlushable.flush();
    if (shouldThrowOnFlush) {
      expectThrown(); 
    } 
    replay(mockFlushable);
  } 
 
  private void doClose(Closeable closeable, boolean swallowException) {
    doClose(closeable, swallowException, !swallowException);
  } 
 
  // Close the closeable using the Closeables, passing in the swallowException 
  // parameter. expectThrown determines whether we expect an exception to 
  // be thrown by Closeables.close; 
  private void doClose(Closeable closeable, boolean swallowException,
4
CodeRank
See Code Examples for Java 8 Flushable Methods: