This commit is contained in:
Administrator
2022-12-27 17:38:49 +08:00
parent 6dd349e722
commit c791720f95
18 changed files with 292 additions and 67 deletions
+42
View File
@@ -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();
}
}
}
}
+41
View File
@@ -0,0 +1,41 @@
package org.kne.io;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
public class AddOutputStream extends OutputStream {
volatile byte out=0;
private OutputStream o;
@Override
public void close() throws IOException {
o.close();
}
@Override
public void flush() throws IOException {
o.flush();
}
public AddOutputStream(OutputStream o) {
super();
this.o = o;
}
@Override
public void write(int b) throws IOException {
o.write((((byte)b)-out)&0xff);
out=(byte) b;
}
public void write(byte[][]e) throws IOException{
for (int y = 0; y < e.length; y++) {
byte tmp[]=e[y];
//System.out.println(Arrays.toString(tmp));
for (int x = 0; x < tmp.length; x++) {
write(tmp[x]&0xFF);
}
}
}
}