From efe46f68a9d0363fd58222048ddfa9efaf1bc9cd Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sat, 18 Jul 2009 00:25:09 +0200 Subject: Added Cleanup features text. --- usage_examples/CleanupExample_post.jpage | 22 ++++++++++++++++++++++ usage_examples/CleanupExample_pre.jpage | 15 +++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 usage_examples/CleanupExample_post.jpage create mode 100644 usage_examples/CleanupExample_pre.jpage (limited to 'usage_examples') diff --git a/usage_examples/CleanupExample_post.jpage b/usage_examples/CleanupExample_post.jpage new file mode 100644 index 00000000..91458459 --- /dev/null +++ b/usage_examples/CleanupExample_post.jpage @@ -0,0 +1,22 @@ +import java.io.*; + +public class CleanupExample { + public static void main(String[] args) throws IOException { + InputStream in = new FileInputStream(args[0]); + try { + OutputStream out = new FileOutputStream(args[1]); + try { + byte[] b = new byte[10000]; + while (true) { + int r = in.read(b); + if (r == -1) break; + out.write(b, 0, r); + } + } finally { + out.close(); + } + } finally { + in.close(); + } + } +} diff --git a/usage_examples/CleanupExample_pre.jpage b/usage_examples/CleanupExample_pre.jpage new file mode 100644 index 00000000..9f639171 --- /dev/null +++ b/usage_examples/CleanupExample_pre.jpage @@ -0,0 +1,15 @@ +import lombok.Cleanup; +import java.io.*; + +public class CleanupExample { + public static void main(String[] args) throws IOException { + @Cleanup InputStream in = new FileInputStream(args[0]); + @Cleanup OutputStream out = new FileOutputStream(args[1]); + byte[] b = new byte[10000]; + while (true) { + int r = in.read(b); + if (r == -1) break; + out.write(b, 0, r); + } + } +} -- cgit