forked from KNEMC/KLALB
V1.0
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package org.kne.io;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class AddInputStream extends InputStream {
|
||||
|
||||
volatile byte out = 0;
|
||||
private InputStream in;
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
int read = in.read();
|
||||
if (read==-1) {
|
||||
return -1;
|
||||
}
|
||||
out = (byte) (out+(byte) read);
|
||||
return out&0xff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
in.close();
|
||||
}
|
||||
|
||||
public AddInputStream(InputStream in) {
|
||||
super();
|
||||
this.in = in;
|
||||
}
|
||||
|
||||
public void read(byte[][] e) throws IOException {
|
||||
for (int y = 0; y<e.length; y++) {
|
||||
byte tmp[] = e[y];
|
||||
|
||||
for (int x = 0; x<tmp.length; x++) {
|
||||
tmp[x] = (byte) read();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user