How to write and read the byte array to DataInput and DataOutput Stream
You didn't initialize your byte array:
byte [] test = null;
Should be:
byte [] test = new byte[length];
You didn't initialize your byte array:
byte [] test = null;
Should be:
byte [] test = new byte[length];