本文整理匯總了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);
}
}