当前位置: 首页>>代码示例>>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;未经允许,请勿转载。