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