com.adobe.internal.io.RangedInputStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aem-sdk-api Show documentation
Show all versions of aem-sdk-api Show documentation
The Adobe Experience Manager SDK
/**
*
*/
package com.adobe.internal.io;
import java.io.IOException;
import java.io.InputStream;
/**
* @author sgill
*
*/
public class RangedInputStream extends CountingInputStream
{
private final long length;
private boolean closed;
/**
* @param in
*/
public RangedInputStream(InputStream in, long length)
{
super(in);
this.length = length;
}
public int read() throws IOException
{
if (this.closed || this.getOffset() == this.length)
{
return -1;
}
return super.read();
}
public int read(byte[] b, int off, int len) throws IOException
{
if (this.closed || this.getOffset() == this.length)
{
return -1;
}
len = (int) Math.min(this.length - this.getOffset(), len);
return super.read(b, off, len);
}
public int read(byte[] b) throws IOException
{
return this.read(b, 0, b.length);
}
public long skip(long n) throws IOException
{
n = Math.min(this.length - this.getOffset(), n);
return super.skip(n);
}
public void close() throws IOException
{
this.closed = true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy