本文整理汇总了Java中java.io.Flushable.flush方法的典型用法代码示例。如果您正苦于以下问题:Java Flushable.flush方法的具体用法?Java Flushable.flush怎么用?Java Flushable.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.Flushable
的用法示例。
在下文中一共展示了Flushable.flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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();
}
示例3: 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;
}
示例4: 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);
}
}
示例5: flushQuietly
import java.io.Flushable; //导入方法依赖的package包/类
public static void flushQuietly(Flushable flushable) {
if (flushable == null) return;
try {
flushable.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: flushQuietly
import java.io.Flushable; //导入方法依赖的package包/类
/**
* 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) {
}
}
}
示例7: flushOrLog
import java.io.Flushable; //导入方法依赖的package包/类
public static void flushOrLog(Flushable f, String message) {
if (f != null) {
try {
f.flush();
} catch (IOException e) {
Fabric.getLogger().e(Fabric.TAG, message, e);
}
}
}
示例8: 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);
}
}
示例9: flush
import java.io.Flushable; //导入方法依赖的package包/类
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;
}
示例10: flush
import java.io.Flushable; //导入方法依赖的package包/类
/**
* 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;
}
}
}
示例11: safeFlush
import java.io.Flushable; //导入方法依赖的package包/类
/**
* 安全刷新一个可刷新的对象,可接受 null
*
* @param fa
* 可刷新对象
*/
public static void safeFlush(Flushable fa) {
if (null != fa)
try {
fa.flush();
}
catch (IOException e) {}
}
示例12: dump
import java.io.Flushable; //导入方法依赖的package包/类
/**
* Copie des flux de <code>in</code> vers <code>out</code>.
*
* @param in
* Flux depuis lequel les donn�es seront lues
* @param out
* Flux vers lequel les donn�es seront �crites
* @throws IOException
* Erreur E/S
*/
private final void dump(Readable in, Appendable out) throws IOException {
try {
try {
Flushable flushable = null;
if (out instanceof Flushable) {
flushable = ((Flushable) out);
}
Thread current = Thread.currentThread();
CharBuffer cb = CharBuffer.allocate(BUF_SIZE);
int len;
cb.clear();
while (!current.isInterrupted() && (len = in.read(cb)) > 0
&& !current.isInterrupted()) {
cb.position(0).limit(len);
out.append(cb);
cb.clear();
if (flushable != null) {
flushable.flush();
}
}
} finally {
tryToClose(in);
}
} finally {
tryToClose(out);
}
}
示例13: safeFlush
import java.io.Flushable; //导入方法依赖的package包/类
private void safeFlush(Flushable f) {
try {
if (f != null)
f.flush();
} catch (Exception e) {
reportError("Error on flush", e, ErrorManager.FLUSH_FAILURE);
} catch (Throwable t) {
// ignored
}
}
示例14: flushQuietly
import java.io.Flushable; //导入方法依赖的package包/类
public static void flushQuietly(Flushable flushable) {
if (flushable != null)
try {
flushable.flush();
} catch (Exception ignored) {
}
}
示例15: dump
import java.io.Flushable; //导入方法依赖的package包/类
/**
* Copie des flux de <code>in</code> vers <code>out</code>.
*
* @param in
* Flux depuis lequel les donnees seront lues
* @param out
* Flux vers lequel les donnees seront ecrites
* @throws IOException
* Erreur E/S
*/
private final void dump(Readable in, Appendable out) throws IOException {
try {
try {
Flushable flushable = null;
if (out instanceof Flushable) {
flushable = ((Flushable) out);
}
Thread current = Thread.currentThread();
CharBuffer cb = CharBuffer.allocate(BUF_SIZE);
int len;
cb.clear();
while (!current.isInterrupted() && (len = in.read(cb)) > 0
&& !current.isInterrupted()) {
cb.position(0).limit(len);
out.append(cb);
cb.clear();
if (flushable != null) {
flushable.flush();
}
}
} finally {
tryToClose(in);
}
} finally {
tryToClose(out);
}
}