@Target(value=LOCAL_VARIABLE) @Retention(value=SOURCE) public @interface Cleanup
Complete documentation is found at the project lombok features page for @Cleanup.
Example:
public void copyFile(String in, String out) throws IOException { @Cleanup FileInputStream inStream = new FileInputStream(in); @Cleanup FileOutputStream outStream = new FileOutputStream(out); byte[] b = new byte[65536]; while (true) { int r = inStream.read(b); if (r == -1) break; outStream.write(b, 0, r); } }Will generate:
public void copyFile(String in, String out) throws IOException { @Cleanup FileInputStream inStream = new FileInputStream(in); try { @Cleanup FileOutputStream outStream = new FileOutputStream(out); try { byte[] b = new byte[65536]; while (true) { int r = inStream.read(b); if (r == -1) break; outStream.write(b, 0, r); } } finally { if (outStream != null) outStream.close(); } } finally { if (inStream != null) inStream.close(); } }
public abstract String value
Copyright © 2024. All rights reserved.