I have a list of OutputStream
to deal with, and I know when I only need one, I can make sure it is closed using try-with-resources
pattern, like:
try(OutputStream os = new ByteArrayOutputStream()) {
do something...
} catch (IOException e) {
do something...
}
But what if there is a list of them? Can I just put the list(ArrayList
or normal array) in the parentheses after try
?