当前位置: 首页>>代码示例>>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;未经允许,请勿转载。