Write:
first write the length of your list, and then write the item in list one by
one

Read:
read the length of your list, initialized your list and read the item one by
one, and append the item to list

I suggest you use array instead of list



On Thu, Oct 15, 2009 at 12:01 PM, z3r0c001 <ceo.co...@gmail.com> wrote:

> I'm trying to implement Writable interface. but not sure how to
> serialize/write/read data from nested objects in
>
> public class StorageClass implements Writable{
>
> public String xStr;
> public String yStr;
>
> public List<SubStorage> sStor
>
> //omitted ctors
>
>
> @override
> public void write(DataOutput out) throws IOException{
>    out.writeChars(xStr);
>    out.WriteChars(yStr);
>
>    //WHAT SHOULD I DO FOR List<SubStorage>
>
> }
>
> @override
> public void readFields(DataInput in) throws IOException{
>    xStr = in.readLine();
>    yStr = in.readLine();
>
>    //WHAT SHOULD I DO FOR List<SubStorage>
> }
>
> }
>
> public class SubStorage{
>    public String x;
>    public String y;
> }
>

Reply via email to