2012-05-11 23:43:27 +00:00
|
|
|
/* Copyright (c) 2008-2011, Avian Contributors
|
2008-02-19 18:06:52 +00:00
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software
|
|
|
|
for any purpose with or without fee is hereby granted, provided
|
|
|
|
that the above copyright notice and this permission notice appear
|
|
|
|
in all copies.
|
|
|
|
|
|
|
|
There is NO WARRANTY for this software. See license.txt for
|
|
|
|
details. */
|
|
|
|
|
2007-07-25 00:34:45 +00:00
|
|
|
package java.io;
|
|
|
|
|
2012-11-04 00:56:06 +00:00
|
|
|
public abstract class InputStream implements Closeable {
|
2007-07-25 00:34:45 +00:00
|
|
|
public abstract int read() throws IOException;
|
|
|
|
|
|
|
|
public int read(byte[] buffer) throws IOException {
|
|
|
|
return read(buffer, 0, buffer.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int read(byte[] buffer, int offset, int length) throws IOException {
|
|
|
|
for (int i = 0; i < length; ++i) {
|
|
|
|
int c = read();
|
|
|
|
if (c == -1) {
|
|
|
|
if (i == 0) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
buffer[offset + i] = (byte) (c & 0xFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
2007-08-30 23:31:32 +00:00
|
|
|
public long skip(long count) throws IOException {
|
|
|
|
final long Max = 8 * 1024;
|
|
|
|
int size = (int) (count < Max ? count : Max);
|
|
|
|
byte[] buffer = new byte[size];
|
|
|
|
long remaining = count;
|
|
|
|
int c;
|
|
|
|
while ((c = read(buffer, 0, (int) (size < remaining ? size : remaining)))
|
|
|
|
>= 0
|
2008-07-14 03:54:07 +00:00
|
|
|
&& remaining > 0) {
|
2007-08-30 23:31:32 +00:00
|
|
|
remaining -= c;
|
|
|
|
}
|
|
|
|
return count - remaining;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int available() throws IOException {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-03-21 00:40:18 +00:00
|
|
|
public void mark(int limit) {
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
|
|
|
|
public void reset() throws IOException {
|
2011-10-20 19:45:47 +00:00
|
|
|
throw new IOException("mark/reset not supported");
|
2008-03-21 00:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean markSupported() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-07-25 00:34:45 +00:00
|
|
|
public void close() throws IOException { }
|
|
|
|
}
|