當前位置: 首頁>>代碼示例>>Java>>正文


Java IOException.getSuppressed方法代碼示例

本文整理匯總了Java中java.io.IOException.getSuppressed方法的典型用法代碼示例。如果您正苦於以下問題:Java IOException.getSuppressed方法的具體用法?Java IOException.getSuppressed怎麽用?Java IOException.getSuppressed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.IOException的用法示例。


在下文中一共展示了IOException.getSuppressed方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getConnectionIOException_multiple

import java.io.IOException; //導入方法依賴的package包/類
@Test public void getConnectionIOException_multiple() {
  IOException firstException = new IOException();
  IOException secondException = new IOException();
  IOException thirdException = new IOException();
  RouteException re = new RouteException(firstException);
  re.addConnectException(secondException);
  re.addConnectException(thirdException);

  IOException connectionIOException = re.getLastConnectException();
  assertSame(thirdException, connectionIOException);
  Throwable[] thirdSuppressedExceptions = thirdException.getSuppressed();
  assertSame(secondException, thirdSuppressedExceptions[0]);

  Throwable[] secondSuppressedException = secondException.getSuppressed();
  assertSame(firstException, secondSuppressedException[0]);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:RouteExceptionTest.java

示例2: close

import java.io.IOException; //導入方法依賴的package包/類
/**
 * Closes all currently open files.
 * Calling this method will not prevent the factory to open new files, i.e. this method can be called multiple times and is not idempotent.
 * 
 * @throws IOException
 */
@Override
public synchronized void close() throws IOException {
	IOException exception = new IOException("At least one open file could not be closed.");
	for (Iterator<Map.Entry<Long, OpenFile>> it = openFiles.entrySet().iterator(); it.hasNext();) {
		Map.Entry<Long, OpenFile> entry = it.next();
		OpenFile openFile = entry.getValue();
		LOG.warn("Closing unclosed file {}", openFile);
		try {
			openFile.close();
		} catch (IOException e) {
			exception.addSuppressed(e);
		}
		it.remove();
	}
	if (exception.getSuppressed().length > 0) {
		throw exception;
	}
}
 
開發者ID:cryptomator,項目名稱:fuse-nio-adapter,代碼行數:25,代碼來源:OpenFileFactory.java

示例3: checkException

import java.io.IOException; //導入方法依賴的package包/類
static void checkException(IOException e, TestCloseable... closeablesWithException) {
    assertEquals(closeablesWithException[0].closeException, e);
    Throwable[] suppressed = e.getSuppressed();
    assertEquals(closeablesWithException.length - 1, suppressed.length);
    for (int i = 1; i < closeablesWithException.length; i++)
        assertEquals(closeablesWithException[i].closeException, suppressed[i - 1]);
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:8,代碼來源:UtilsTest.java


注:本文中的java.io.IOException.getSuppressed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。