Close multiple resources with AutoCloseable (try-with-resources)
I know that the resource you pass with a try, will be closed automatically if the resource has AutoCloseable implemented. So far so good. But what do I do when i have several resources that I want automatically closed. Example with sockets; try (Socket socket = new Socket()) { input = new DataInputStream(socket.getInputStream()); output = new DataOutputStream(socket.getOutputStream()); } catch (IOException e) { } So I know the socket will be closed properly, because it's passed as a parameter in the try, but how should the input and output be closed properly? augray Try with resources can be