本文整理汇总了Java中java.io.Closeable.close方法的典型用法代码示例。如果您正苦于以下问题:Java Closeable.close方法的具体用法?Java Closeable.close怎么用?Java Closeable.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.Closeable
的用法示例。
在下文中一共展示了Closeable.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleClose
import java.io.Closeable; //导入方法依赖的package包/类
private void handleClose(MsgClose m) throws IOException {
int fileID = m.getFileID();
log.info(getName()+": Request close file "+fileID);
Closeable stream;
synchronized (localIS) {
stream = localIS.get(m.getFileID());
}
if (stream == null) { // Maybe an OutputStream?
synchronized (localOS) {
stream = localOS.get(m.getFileID());
}
}
if (stream == null) { // File descriptor not found
log.warning(getName()+": Local file ID "+fileID+" not found");
} else {
try {
stream.close();
log.fine(getName()+": Closed file "+fileID);
} catch (IOException e) { // Exception during skip
log.warning(getName()+": Error when closing file ID "+fileID+": "+e.getMessage());
}
}
}
示例2: closeQuitely
import java.io.Closeable; //导入方法依赖的package包/类
private static void closeQuitely(Closeable stream) {
try {
if (stream != null)
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例3: closeQuietly
import java.io.Closeable; //导入方法依赖的package包/类
/**
* Closes {@code closeable}, ignoring any checked exceptions. Does nothing
* if {@code closeable} is null.
*/
public static void closeQuietly(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (RuntimeException rethrown) {
throw rethrown;
} catch (Exception ignored) {
}
}
}
示例4: closeQuietly
import java.io.Closeable; //导入方法依赖的package包/类
public static void closeQuietly(Closeable closeable) {
if (null == closeable) {
return;
}
try {
closeable.close();
} catch (Throwable t) {
}
}
示例5: closeQuietly
import java.io.Closeable; //导入方法依赖的package包/类
static public void closeQuietly (Closeable closeable) {
if (closeable == null) return;
try {
closeable.close();
} catch (Throwable ignored) {
}
}
示例6: closeIOQuietly
import java.io.Closeable; //导入方法依赖的package包/类
/**
* 安静关闭IO
*
* @param closeables closeable
*/
public static void closeIOQuietly(Closeable... closeables) {
if (closeables == null) return;
for (Closeable closeable : closeables) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException ignored) {
}
}
}
}
示例7: closeOldLoaders
import java.io.Closeable; //导入方法依赖的package包/类
private void closeOldLoaders() throws IOException {
SoftReference<Closeable> ref = loadersToClose.poll();
while (ref != null) {
Closeable closeable = ref.get();
if (closeable != null) {
closeable.close();
}
ref.clear();
ref = loadersToClose.poll();
}
}
示例8: closeResource
import java.io.Closeable; //导入方法依赖的package包/类
/**
* If the {@code resource} is not {@code null}, this method will try to close the
* {@code resource} instance and log warning about any unexpected
* {@link IOException} that may occur.
*
* @param resource resource to be closed
*/
public static void closeResource(Closeable resource) {
if (resource != null) {
try {
resource.close();
} catch (IOException e) {
LOGGER.warning(LocalizationMessages.WSP_0023_UNEXPECTED_ERROR_WHILE_CLOSING_RESOURCE(resource.toString()), e);
}
}
}
示例9: closeIOQuietly
import java.io.Closeable; //导入方法依赖的package包/类
/**
* 安静关闭IO
*
* @param closeables closeables
*/
public static void closeIOQuietly(final Closeable... closeables) {
if (closeables == null) return;
for (Closeable closeable : closeables) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException ignored) {
}
}
}
}
示例10: closeSilently
import java.io.Closeable; //导入方法依赖的package包/类
public static void closeSilently( Closeable c ) {
if ( null != c ) {
try {
c.close();
} catch (Throwable t) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
}
}
示例11: closeSilently
import java.io.Closeable; //导入方法依赖的package包/类
/** close things if not null, for use in finally blocks, swallows exceptions */
public static void closeSilently(final Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException e) {
// silence
}
}
}
示例12: a
import java.io.Closeable; //导入方法依赖的package包/类
public static void a(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (Throwable th) {
}
}
}
示例13: closeQuietly
import java.io.Closeable; //导入方法依赖的package包/类
private static void closeQuietly(Closeable closeable)
{
try
{
if (closeable != null)
{
closeable.close();
}
}
catch (IOException e)
{
}
}
示例14: closeQuietly
import java.io.Closeable; //导入方法依赖的package包/类
static void closeQuietly(/*Auto*/Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (RuntimeException rethrown) {
throw rethrown;
} catch (Exception ignored) {
}
}
}
示例15: cleanup
import java.io.Closeable; //导入方法依赖的package包/类
/**
* Close the Closeable objects and <b>ignore</b> any {@link IOException} or
* null pointers. Must only be used for cleanup in exception handlers.
*
* @param log
* the log to record problems to at debug level. Can be null.
* @param closeables
* the objects to close
*/
public static void cleanup(Logger log, Closeable... closeables) {
for (Closeable c : closeables) {
if (c != null) {
try {
c.close();
} catch (IOException e) {
if (log != null) {
log.warn("Exception in closing " + c, e);
}
}
}
}
}