當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。