File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes 2-dimension array data streaming. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "2-dimension array data streaming." Watch "2-dimension array data streaming." New topic
Author

2-dimension array data streaming.

Aji Prasetyo
Ranch Hand

Joined: Jun 13, 2007
Posts: 65
hello,

I am always having hard time when dealing with java array.
This time I want to stream a 2-dimension array into a file and send it through TCP/IP socket.

How do I do that?

Thank you so much beforehand.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Hi, what have you tried? Have you been able to send other data? There are a lot of protocol options. It would be great if you've already chosen one and made it work for something simple. If not, we can talk about the listener on the other end and some of the choices.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Aji Prasetyo
Ranch Hand

Joined: Jun 13, 2007
Posts: 65
Hi Stan,

Thank you for the quick reply, honestly I didn't expect to be this fast (the thing I like about this forum )

what have you tried? Have you been able to send other data?


Actually I have been able to send a DatagramPacket through DatagramSocket, but now I want to make a TCP/IP connection; no luck so far .
But before I get into that, I think I need to put the data to be send; which is in form of 2-dimensional int array, into a file. As fas as I see I need to change the 2-dimensional int array into byte[] so it can be buffered, but don't know how.

I am sorry if I make a stupid statements, I am still learning....

Thank you so much.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Turning your data into byte[] is one choice. Another is to use Java Serialization which is ideal for sending objects over the wire. HERE is an example using arrays.

Sounds like you ought to back up though and think about arrays separate from your socket goal. What you're calling a 2-dimensional array is really an array where every entry is another array, or more simply an array of arrays. Can you write code to iterate through all the elements in such an array?
Aji Prasetyo
Ranch Hand

Joined: Jun 13, 2007
Posts: 65
Hello again Stan,

Just want to say thanks for your direction.
Java Serialization is what I need indeed.

Good luck and God Bless You...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 2-dimension array data streaming.