1 2 3 4 package net.nutch.io; 5 6 import java.io.IOException ; 7 import java.io.DataInput ; 8 import java.io.DataOutput ; 9 10 14 public class BytesWritable implements Writable { 15 private byte[] bytes; 16 17 public BytesWritable() {} 18 19 public BytesWritable(byte[] bytes) { 20 this.bytes = bytes; 21 } 22 23 public byte[] get() { 24 return bytes; 25 } 26 27 public void readFields(DataInput in) throws IOException { 28 bytes = new byte[in.readInt()]; 29 in.readFully(bytes, 0, bytes.length); 30 } 31 32 public void write(DataOutput out) throws IOException { 33 out.writeInt(bytes.length); 34 out.write(bytes); 35 } 36 37 } 38 | Popular Tags |