Java 从ImageInputStream提供InputStream的最佳方法

Java 从ImageInputStream提供InputStream的最佳方法,java,inputstream,javax.imageio,Java,Inputstream,Javax.imageio,我有一个ImageInputStream。我正在使用一个需要InputStream源的第三方API。我编写了一个要传递给API的包装器类: class ImageInputStreamWrapper extends InputStream { private ImageInputStream imageInputStream; public ImageInputStreamWrapper(ImageInputStream is) { imageInputStr

我有一个ImageInputStream。我正在使用一个需要InputStream源的第三方API。我编写了一个要传递给API的包装器类:

class ImageInputStreamWrapper extends InputStream {

    private ImageInputStream imageInputStream;

    public ImageInputStreamWrapper(ImageInputStream is) {
        imageInputStream = is;
    }

    public int read() throws IOException {
        return imageInputStream.read();
    }

}

它可以工作,但速度非常慢。有更好的方法吗?

找到了。我需要补充:

public int read(byte[] b, int off, int len) throws IOException {
    return imageInputStream.read(b, off, len);
}