日期:2014-05-20 浏览次数:21542 次
public void writeTo(DataOutput out) throws IOException{
out.writeChars("sexgirl.jpg");
out.writeLong(181818);//181818 是图片数据的长度
//write the image data into out
out.writeChars("sexboy.jpg");
out.writeLong(181817);//181817 是另一图片数据的长度
//write the other image data into out
}
public void readFrom(DataInput in) throws IOException{
String name1 = in.readLine();
long size1 = in.readLong();//这是第一张图片的大小
byte[] data1 = new byte[(int) size1];
for(int i=0;i<size1;i++){//读取图片数据
data1[i] = in.readByte();
}
String name2 = in.readLine();
long size2 = in.readLong();//这是第二张图片的大小
byte[] data2 = new byte[(int) size2];
for(int i=0;i<size2;i++){//读取图片数据
data2[i] = in.readByte();
}
}