W nowej składni Try-with-Resources w Java 7, czy muszę się martwić kolejnością zasobów?Try-with-resources w Java 7?
try (InputStream in = loadInput(...); // <--- can these be in any order?
OutputStream out = createOutput(...)){
copy(in, out);
}
catch (Exception e) {
// Problem reading and writing streams.
// Or problem opening one of them.
// If compound error closing streams occurs, it will be recorded on this exception
// as a "suppressedException".
}
Jeśli zasoby zależą od * siebie *, tak (dobrze, "może" w zależności od siebie o tym, jak to robią). W przeciwnym razie ... nie. –