UPDATE2: My own version of the adapter class, that only calls instanceof
in the constructor and uses a (Java 1.5) delta in the flush()
and cl
You can accept any Appendable
and then check if it is a Writer
through instanceof
. Then do a downcast and call that function that accepts only Writer
.
example:
public void myMethod(Appendable app) throws InvalidAppendableException {
if (app instanceof Writer) {
someObj.thatMethod((Writer) app);
} else {
throw new InvalidAppendableException();
}
}