Skip to content

Instantly share code, notes, and snippets.

@HyeonUkCho
Created October 22, 2019 10:31
Show Gist options
  • Save HyeonUkCho/27c1418058873eab01a5835c8f8ae8b7 to your computer and use it in GitHub Desktop.
Save HyeonUkCho/27c1418058873eab01a5835c8f8ae8b7 to your computer and use it in GitHub Desktop.
public void testCleanUp() {
try {
@Cleanup ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(new byte[] {'Y','e','s'});
System.out.println(baos.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
public void testCleanUp() {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
baos.write(new byte[]{'Y', 'e', 's'});
System.out.println(baos.toString());
} finally {
baos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment