public static void rethrowIOException(Throwable cause)
            throws IOException {
        if (cause instanceof IOException) {
            throw (IOException) cause;
        } else if (cause instanceof RuntimeException) {
            throw (RuntimeException) cause;
        } else if (cause instanceof Error) {
            throw (Error) cause;
        } else {
            throw new IOException(cause.getMessage(), cause);
        }
    }
@Test
    public void testRethrowIOException() {
        IOException ioe = new IOException("test");
        try {
            rethrowIOException(ioe);
            fail("Should rethrow IOException");
        } catch (IOException e) {
            assertSame(ioe, e);
        }
    }