当前位置: 首页>>代码示例>>Java>>正文


Java Closeable.close方法代码示例

本文整理汇总了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());
		}
	}
}
 
开发者ID:matthieu-labas,项目名称:JRF,代码行数:24,代码来源:JRFProvider.java

示例2: closeQuitely

import java.io.Closeable; //导入方法依赖的package包/类
private static void closeQuitely(Closeable stream) {
    try {
        if (stream != null)
            stream.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:9,代码来源:ZipUtils.java

示例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) {
    }
  }
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:15,代码来源:Util.java

示例4: closeQuietly

import java.io.Closeable; //导入方法依赖的package包/类
public static void closeQuietly(Closeable closeable) {
	if (null == closeable) {
		return;
	}
	try {
		closeable.close();
	} catch (Throwable t) {
	}
}
 
开发者ID:zhaoshiling1017,项目名称:voyage,代码行数:10,代码来源:IOUtil.java

示例5: closeQuietly

import java.io.Closeable; //导入方法依赖的package包/类
static public void closeQuietly (Closeable closeable) {
	if (closeable == null) return;
	try {
		closeable.close();
	} catch (Throwable ignored) {
	}
}
 
开发者ID:EsotericSoftware,项目名称:tcpserver,代码行数:8,代码来源:Util.java

示例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) {
            }
        }
    }
}
 
开发者ID:guiying712,项目名称:AndroidModulePattern,代码行数:17,代码来源:CloseUtils.java

示例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();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:12,代码来源:DefaultVersionedPlayRunAdapter.java

示例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);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:PolicyUtils.java

示例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) {
            }
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:CloseUtils.java

示例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();
        }
    }
}
 
开发者ID:mithrilcoin-io,项目名称:EosCommander,代码行数:11,代码来源:Utils.java

示例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
        }
    }
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:11,代码来源:IOUtils.java

示例12: a

import java.io.Closeable; //导入方法依赖的package包/类
public static void a(Closeable closeable) {
    if (closeable != null) {
        try {
            closeable.close();
        } catch (Throwable th) {
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:jn.java

示例13: closeQuietly

import java.io.Closeable; //导入方法依赖的package包/类
private static void closeQuietly(Closeable closeable)
{
    try
    {
        if (closeable != null)
        {
            closeable.close();
        }
    }
    catch (IOException e)
    {
    }
}
 
开发者ID:Dragon-lake,项目名称:cc,代码行数:14,代码来源:FileUtil.java

示例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) {
		}
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:Util.java

示例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);
                }
            }
        }
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:23,代码来源:IOUtils.java


注:本文中的java.io.Closeable.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。