ByteArrayOutputStream outStreamOdd = new ByteArrayOutputStream();
ByteArrayOutputStream outStreamEven = new ByteArrayOutputStream();
OutputStream out = (OutputStream)HotSwapping.object(OutputStream.class, new CglibProxyFactory(), null);
PrintWriter writer = new PrintWriter(out);
for (int i = 0; i < 10; ++i) {
Swappable swappable = (Swappable)out;
if (i % 2 > 0) {
swappable.hotswap(outStreamEven);
} else {
swappable.hotswap(outStreamOdd);
}
writer.println("Line " + (i + 1));
writer.flush();
}
System.out.println();