类java.io.Flushable源码实例Demo

下面列出了怎么用java.io.Flushable的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: sylph   文件: 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;
}
 
源代码2 项目: AndroidRipper   文件: WrapProcess.java
private void connect(final Readable source, final Appendable sink) {
	Thread thread = new Thread(new Runnable() {
		public void run() {
			CharBuffer cb = CharBuffer.wrap(new char [256]);
			try {
				while (source.read(cb) != -1) {
					cb.flip();
					sink.append(cb);
					cb.clear();
				}

				if (sink instanceof Flushable) {
					((Flushable)sink).flush();
				}
			} catch (IOException e) { /* prolly broken pipe, just die */ }
		}
	});
	thread.setDaemon(true);
	thread.start();
}
 
源代码3 项目: journalkeeper   文件: StateWrapper.java
public StateWrapper(WrappedState<E, ER, Q, QR> wrappedState, SerializeExtensionPoint serializeExtensionPoint) {
    this.serializeExtensionPoint = serializeExtensionPoint;
    this.wrappedState = wrappedState;
    if (wrappedState instanceof Flushable) {
        flushable = (Flushable) wrappedState;
    } else {
        flushable = null;
    }
}
 
源代码4 项目: Bopomofo4j   文件: 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();
}
 
源代码5 项目: alltv   文件: 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();
}
 
public void close() {
   this.baseImplementation.stop();
   AppenderAttachableImpl var1 = this.downstreamAppenders;
   synchronized(this.downstreamAppenders) {
      Enumeration enumer = this.downstreamAppenders.getAllAppenders();

      while(enumer != null && enumer.hasMoreElements()) {
         Appender appender = (Appender)enumer.nextElement();
         if (appender instanceof Flushable) {
            try {
               ((Flushable)appender).flush();
            } catch (Exception var6) {
               ;
            }
         }
      }

      enumer = this.downstreamAppenders.getAllAppenders();

      while(true) {
         if (enumer == null || !enumer.hasMoreElements()) {
            break;
         }

         ((Appender)enumer.nextElement()).close();
      }
   }

   this.closed = true;
}
 
源代码7 项目: pushfish-android   文件: AnsiConsole.java
public AnsiConsole(Appendable target, Flushable flushable, ColorMap colorMap) {
    this.target = target;
    this.flushable = flushable;
    this.colorMap = colorMap;
    container = new Screen();
    textArea = new TextAreaImpl(container);
}
 
源代码8 项目: pushfish-android   文件: AnsiConsole.java
public AnsiConsole(Appendable target, Flushable flushable, ColorMap colorMap) {
    this.target = target;
    this.flushable = flushable;
    this.colorMap = colorMap;
    container = new Screen();
    textArea = new TextAreaImpl(container);
}
 
源代码9 项目: cucumber-performance   文件: NiceAppendable.java
private void tryFlush()  {
    if (!(out instanceof Flushable))
        return;
    try {
        ((Flushable) out).flush();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
源代码10 项目: DoraemonKit   文件: IOUtils.java
public static void flushQuietly(Flushable flushable) {
    if (flushable == null) return;
    try {
        flushable.flush();
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    }
}
 
源代码11 项目: DoraemonKit   文件: IOUtils.java
public static void flushQuietly(Flushable flushable) {
    if (flushable == null) return;
    try {
        flushable.flush();
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    }
}
 
源代码12 项目: Kalle   文件: IOUtils.java
public static void flushQuietly(Flushable flushable) {
    if (flushable != null)
        try {
            flushable.flush();
        } catch (Exception ignored) {
        }
}
 
源代码13 项目: firebase-android-sdk   文件: CommonUtils.java
public static void flushOrLog(Flushable f, String message) {
  if (f != null) {
    try {
      f.flush();
    } catch (IOException e) {
      Logger.getLogger().e(message, e);
    }
  }
}
 
源代码14 项目: text-ui   文件: Utils.java
/**
 * Flush the flushable and catch any exception thrown.
 *
 * @param flushable the flushable to flush
 * @return any Exception thrown during the <code>flush</code> operation
 */
public static Exception flush(Flushable flushable) {
  if (flushable != null) {
    try {
      flushable.flush();
    }
    catch (Exception e) {
      return e;
    }
  }
  return null;
}
 
源代码15 项目: android-discourse   文件: 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();
}
 
源代码16 项目: financisto   文件: Csv.java
public Writer flush() {
    try {
        if (appendable instanceof Flushable) {
            Flushable flushable = (Flushable) appendable;
            flushable.flush();
        }
    } catch (java.io.IOException e) { throw new IOException(e); }
    return this;
}
 
源代码17 项目: 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();
}
 
源代码18 项目: 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);
        }
    }
}
 
源代码19 项目: FireFiles   文件: 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) {
        }
    }
}
 
源代码20 项目: FireFiles   文件: 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) {
        }
    }
}
 
源代码21 项目: FireFiles   文件: 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) {
        }
    }
}
 
源代码22 项目: hadoop   文件: TaskLog.java
@SuppressWarnings("unchecked")
private static void flushAppenders(Logger l) {
  final Enumeration<Appender> allAppenders = l.getAllAppenders();
  while (allAppenders.hasMoreElements()) {
    final Appender a = allAppenders.nextElement();
    if (a instanceof Flushable) {
      try {
        ((Flushable) a).flush();
      } catch (IOException ioe) {
        System.err.println(a + ": Failed to flush!"
          + StringUtils.stringifyException(ioe));
      }
    }
  }
}
 
源代码23 项目: ProtocolSupportPocketStuff   文件: 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();
}
 
源代码24 项目: manifold   文件: StreamUtil.java
private static void close( Closeable[] streams, int idx ) throws IOException
{
  if( idx >= streams.length )
  {
    return; // done
  }
  Closeable stream = streams[idx];
  try
  {
    if( stream != null )
    {
      if( stream instanceof Flushable )
      {
        ((Flushable)stream).flush();
      }
      stream.close();
    }
  }
  catch( IOException ex )
  {
    if( !(stream instanceof InputStream || stream instanceof Reader) )
    {
      throw ex; // ignore io exceptions for input streams and readers
    }
  }
  finally
  {
    close( streams, idx + 1 );
  }
}
 
源代码25 项目: AndServer   文件: IOUtils.java
public static void flushQuietly(Flushable flushable) {
    if (flushable != null) {
        try {
            flushable.flush();
        } catch (Exception ignored) {
        }
    }
}
 
源代码26 项目: big-c   文件: TaskLog.java
@SuppressWarnings("unchecked")
private static void flushAppenders(Logger l) {
  final Enumeration<Appender> allAppenders = l.getAllAppenders();
  while (allAppenders.hasMoreElements()) {
    final Appender a = allAppenders.nextElement();
    if (a instanceof Flushable) {
      try {
        ((Flushable) a).flush();
      } catch (IOException ioe) {
        System.err.println(a + ": Failed to flush!"
          + StringUtils.stringifyException(ioe));
      }
    }
  }
}
 
源代码27 项目: okhttp-OkGo   文件: IOUtils.java
public static void flushQuietly(Flushable flushable) {
    if (flushable == null) return;
    try {
        flushable.flush();
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    }
}
 
源代码28 项目: AndPermission   文件: IOUtils.java
public static void flush(Flushable flushable) {
    try {
        flushable.flush();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
源代码29 项目: codebuff   文件: Flushables.java
/**
 * Flush a {@link Flushable}, with control over whether an {@code IOException} may be thrown.
 *
 * <p>If {@code swallowIOException} is true, then we don't rethrow {@code IOException}, but merely
 * log it.
 *
 * @param flushable the {@code Flushable} object to be flushed.
 * @param swallowIOException if true, don't propagate IO exceptions thrown by the {@code flush}
 *     method
 * @throws IOException if {@code swallowIOException} is false and {@link Flushable#flush} throws
 *     an {@code IOException}.
 * @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;
    }
  }
}
 
源代码30 项目: codebuff   文件: 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);
  }
}
 
 类所在包
 类方法
 同包方法