mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-07 09:25:10 +00:00
@@ -26,59 +26,59 @@ import java.io.InputStream;
|
||||
*/
|
||||
public class ReReadableInputStream extends InputStream {
|
||||
|
||||
InputStream is;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] converted;
|
||||
int pos = 0;
|
||||
int count = 0;
|
||||
InputStream is;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] converted;
|
||||
int pos = 0;
|
||||
int count = 0;
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public byte[] getAllRead() {
|
||||
return baos.toByteArray();
|
||||
}
|
||||
public byte[] getAllRead() {
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
public int getPos() {
|
||||
return pos;
|
||||
}
|
||||
public int getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public ReReadableInputStream(InputStream is) {
|
||||
this.is = is;
|
||||
}
|
||||
public ReReadableInputStream(InputStream is) {
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
public void setPos(int pos) throws IOException {
|
||||
if (pos > count) {
|
||||
this.pos = count;
|
||||
skip(pos - count);
|
||||
}
|
||||
this.pos = pos;
|
||||
}
|
||||
public void setPos(int pos) throws IOException {
|
||||
if (pos > count) {
|
||||
this.pos = count;
|
||||
skip(pos - count);
|
||||
}
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if (pos < count) {
|
||||
if (converted == null) {
|
||||
converted = baos.toByteArray();
|
||||
}
|
||||
int ret = converted[pos] & 0xff;
|
||||
pos++;
|
||||
return ret;
|
||||
}
|
||||
int i = is.read();
|
||||
if (i > -1) {
|
||||
baos.write(i);
|
||||
count++;
|
||||
}
|
||||
pos++;
|
||||
converted = null;
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if (pos < count) {
|
||||
if (converted == null) {
|
||||
converted = baos.toByteArray();
|
||||
}
|
||||
int ret = converted[pos] & 0xff;
|
||||
pos++;
|
||||
return ret;
|
||||
}
|
||||
int i = is.read();
|
||||
if (i > -1) {
|
||||
baos.write(i);
|
||||
count++;
|
||||
}
|
||||
pos++;
|
||||
converted = null;
|
||||
|
||||
return i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
return (count + is.available()) - pos;
|
||||
}
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
return (count + is.available()) - pos;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user