/**
* © 2008 INA Service GmbH
*/
+
package net.pterodactylus.util.io;
import java.io.FilterInputStream;
* bytes from the underlying input stream.
*
* @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
*/
public class LimitedInputStream extends FilterInputStream {
*/
@Override
public synchronized int available() throws IOException {
+ if (remaining == 0) {
+ return 0;
+ }
return (int) Math.min(super.available(), Math.min(Integer.MAX_VALUE, remaining));
}
*/
@Override
public synchronized long skip(long n) throws IOException {
- if (n < 0) {
+ if ((n < 0) || (remaining == 0)) {
return 0;
}
long skipped = super.skip(Math.min(n, remaining));
}
/**
- * {@inheritDoc}
- *
- * This method does nothing, as {@link #mark(int)} and {@link #reset()} are
- * not supported.
+ * {@inheritDoc} This method does nothing, as {@link #mark(int)} and
+ * {@link #reset()} are not supported.
*
* @see java.io.FilterInputStream#mark(int)
*/
}
/**
- * {@inheritDoc}
- *
- * This method does nothing, as {@link #mark(int)} and {@link #reset()} are
- * not supported.
+ * {@inheritDoc} This method does nothing, as {@link #mark(int)} and
+ * {@link #reset()} are not supported.
*
* @see java.io.FilterInputStream#reset()
*/