Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String [ ][ ] Outputstream Question

Status
Not open for further replies.

ezl

Programmer
Aug 7, 2001
8
US
Hi...

I think this is pretty simple (hopefully!)...

I want to write a two dimensional array of Strings to an ouput stream (to sent the data to another machine). Elsewhere in my program I'm successfully doing the same thing for text using the following code (note IPConnect is my own class...it just creates the socket):

IPconnect ipConnection=new IPconnect();
OutputStream out=ipConnection.connect( ipVar, portVar);
DataOutputStream dataOut=new DataOutputStream(out);
dataOut.writeUTF("Outgoing String");

How would I accomplish the same thing, but passing a two dimensional array instead of text?

Thanks in advance...

ezl
 
Hey,

If the array looks something like this:

[] [] [] [] [] [] ...
[] [] [] [] [] [] ...
[] [] [] [] [] [] ...
...

then all i did with a similar kind of problem was to iterate through each "row" of the 2-dimensional array and convert this row to a vector and then write each vector to the stream separately. Not sure if this is the best way to do it, but in my case i wanted to modify the contents of the array "rows" before outputting it - easier to do in a vector than an array in my experience!

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top