ArrayList of ArrayList to byte[]

T

TJO

I am looking for an approach that would allow me to transform an ArrayList
of ArrayLists into a byte[] and vise versa.

Each item in the ArrayList is an ArrayList of Point objects which represent
one continous line. I need this byte[] so I can stream on a socket so it
can be recreated at the server end. Any suggestion would be greatly
appreciated.

Thanks
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

The tricky part is how to indicate to the other end when a new arraylist
start, I would define a protocol looking something like this:
NEWARRAY
ARRAYLENGTH=XXXX
...
data
...

in this way you can reconstruct the exact same structure in the receiver.

You could also take a look at the serialization features of the framework,
but the above approach will work no matter what the receiver is weather the
serialization only works with .NET apps in both ends.

Cheers,
 
S

Stefan Simek

Hmmm... unless you want to use a binary format, I guess it would be best to
serialize it as XML and then just convert it to byte[] using an Encoding.

HTH,
Stefan

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

The tricky part is how to indicate to the other end when a new arraylist
start, I would define a protocol looking something like this:
NEWARRAY
ARRAYLENGTH=XXXX
..
data
..

in this way you can reconstruct the exact same structure in the receiver.

You could also take a look at the serialization features of the framework,
but the above approach will work no matter what the receiver is weather
the
serialization only works with .NET apps in both ends.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



TJO said:
I am looking for an approach that would allow me to transform an
ArrayList
of ArrayLists into a byte[] and vise versa.

Each item in the ArrayList is an ArrayList of Point objects which represent
one continous line. I need this byte[] so I can stream on a socket so it
can be recreated at the server end. Any suggestion would be greatly
appreciated.

Thanks
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

It all depends of the receiver end, sending them as byte with an indication
of where one ends make it easy to interop with any other application.


cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Stefan Simek said:
Hmmm... unless you want to use a binary format, I guess it would be best to
serialize it as XML and then just convert it to byte[] using an Encoding.

HTH,
Stefan

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:[email protected]...
Hi,

The tricky part is how to indicate to the other end when a new arraylist
start, I would define a protocol looking something like this:
NEWARRAY
ARRAYLENGTH=XXXX
..
data
..

in this way you can reconstruct the exact same structure in the receiver.

You could also take a look at the serialization features of the framework,
but the above approach will work no matter what the receiver is weather
the
serialization only works with .NET apps in both ends.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



TJO said:
I am looking for an approach that would allow me to transform an
ArrayList
of ArrayLists into a byte[] and vise versa.

Each item in the ArrayList is an ArrayList of Point objects which represent
one continous line. I need this byte[] so I can stream on a socket so it
can be recreated at the server end. Any suggestion would be greatly
appreciated.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top