我正在尝试编写一个实用程序,它以重新激活的方式自动传播已检查的异常,而无需在我的运算符中编写带有静态块的样板代码:
public class ReactRethrow {
public static <T, R> Function<T, R> rethrow(Function<T, R> catchedFunc) {
return t -> {
try {
return catchedFunc.apply(t);
} catch (Exception e) {
throw Exceptions.propagate(e);
}
};
}
}
但它仍抱怨IOException:
Flux.fromArray(resources).map(ReactRethrow.rethrow(resource -> Paths.get(resource.getURI())))
任何想法?
答案 0 :(得分:1)
有一个原因我不清楚你理解你必须把一个抛出异常的函数作为参数,因此声明一个特定的functionalInterface:
<body onload="createPlayer(); check()">
<div id="demo"></div>
<button onclick="prevItem()" id="prev_btn"><img src="assets/next-button.png" alt=prev>
<br>
</button> <button onclick="nextItem()" id=next_btn><img src="assets/next-button.png" alt=next></button>
<div id="number"></div>
</body>
从这里https://leoniedermeier.github.io/docs/java/java8/streams_with_checked_exceptions.html