@@ -0,0 +1,1909 @@
+package net.darkmist.alib.io;%0A%0Aimport java.io.DataInput;%0Aimport java.io.DataOutput;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0Aimport java.io.OutputStreamWriter;%0Aimport java.io.Reader;%0Aimport java.io.Writer;%0A%0Apublic class DataIOUtil%0A%7B%0A%09/**%0A%09 * Only stati methods.%0A%09 */%0A%09private DataIOUtil()%0A%09%7B%0A%09%7D%0A%0A%09private static class DataInputAsStream extends InputStream%0A%09%7B%0A%09%09private DataInput din;%0A%0A%09%09DataInputAsStream(DataInput din)%0A%09%09%7B%0A%09%09%09if((this.din = din)==null)%0A%09%09%09%09throw new NullPointerException(%22DataInput cannot be null.%22);%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public int read() throws IOException%0A%09%09%7B%0A%09%09%09return din.readByte();%0A%09%09%7D%0A%0A%09%09// note that DataOutput.readFully does NOT follow the same%0A%09%09// samantics as read(byte%5B%5D...) so is not directly wrapped.%0A%09%7D%0A%0A%09public static InputStream asInputStream(DataInput din)%0A%09%7B%0A%09%09if(din instanceof InputStream)%0A%09%09%09return (InputStream)din;%0A%09%09return new DataInputAsStream(din);%0A%09%7D%0A%0A%09public static Reader asReader(DataInput din)%0A%09%7B%0A%09%09return new InputStreamReader(asInputStream(din));%0A%09%7D%0A%0A%09private static class DataOutputAsStream extends OutputStream%0A%09%7B%0A%09%09private DataOutput dout;%0A%0A%09%09DataOutputAsStream(DataOutput dout)%0A%09%09%7B%0A%09%09%09if((this.dout = dout)==null)%0A%09%09%09%09throw new NullPointerException(%22DataOutput cannot be null.%22);%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public void write(int b) throws IOException%0A%09%09%7B%0A%09%09%09dout.write(b);%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public void write(byte%5B%5D bytes, int off, int len) throws IOException%0A%09%09%7B%0A%09%09%09dout.write(bytes, off, len);%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public void write(byte%5B%5D bytes) throws IOException%0A%09%09%7B%0A%09%09%09dout.write(bytes);%0A%09%09%7D%0A%09%7D%0A%0A%09public static OutputStream asOutputStream(DataOutput dout)%0A%09%7B%0A%09%09if(dout instanceof OutputStream)%0A%09%09%09return (OutputStream)dout;%0A%09%09return new DataOutputAsStream(dout);%0A%09%7D%0A%0A%09public static Writer asWriter(DataOutput dout)%0A%09%7B%0A%09%09return new OutputStreamWriter(asOutputStream(dout));%0A%09%7D%0A%7D%0A

Add utils for DataInput & DataOutput