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


Java Flushable.flush方法代碼示例

本文整理匯總了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);
   }
}
 
開發者ID:wellsb1,項目名稱:fort_j,代碼行數:17,代碼來源:Streams.java

示例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();
}
 
開發者ID:jjfiv,項目名稱:chai,代碼行數:26,代碼來源:MemoryNotifier.java

示例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;
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:19,代碼來源:Flushables.java

示例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);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:IOUtils.java

示例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();
    }
}
 
開發者ID:CodingCodersCode,項目名稱:EvolvingNetLib,代碼行數:9,代碼來源:CCIOUtils.java

示例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) {
        }
    }
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:14,代碼來源:IoUtils.java

示例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);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:10,代碼來源:CommonUtils.java

示例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);
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:11,代碼來源:IOUtils.java

示例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;
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:10,代碼來源:Csv.java

示例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;
    }
  }
}
 
開發者ID:antlr,項目名稱:codebuff,代碼行數:27,代碼來源:Flushables.java

示例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) {}
}
 
開發者ID:cowthan,項目名稱:JavaAyo,代碼行數:14,代碼來源:Streams.java

示例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);
	}
}
 
開發者ID:dgrandemange,項目名稱:txnmgrflow-docgen-maven-plugin,代碼行數:39,代碼來源:ProcessConsumer.java

示例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
  }
}
 
開發者ID:kifj,項目名稱:wildfly-logstash,代碼行數:11,代碼來源:SocketHandler.java

示例14: flushQuietly

import java.io.Flushable; //導入方法依賴的package包/類
public static void flushQuietly(Flushable flushable) {
    if (flushable != null)
        try {
            flushable.flush();
        } catch (Exception ignored) {
        }
}
 
開發者ID:yanzhenjie,項目名稱:NoHttp,代碼行數:8,代碼來源:IOUtils.java

示例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);
	}
}
 
開發者ID:Spirals-Team,項目名稱:peak-forecast,代碼行數:39,代碼來源:ProcessConsumer.java


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