Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static AutoCloseable of(List<? extends AutoCloseable> l) {
- return () ->
- l.forEach(ac -> {
- try {
- ac.close();
- } catch (Exception e) {
- // ...
- }
- });
- }
- public static void main(String[] args) throws Exception {
- List<ByteArrayOutputStream> oss = new ArrayList<>();
- try (AutoCloseable toBeAutoClosed = of(oss)) {
- System.out.println("Hello");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment