Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-30-2007, 01:34 PM
eva eva is offline
Member
 
Join Date: Dec 2007
Posts: 49
eva is on a distinguished road
Sending a Vector to TCP server
Hi,

I want to send a Vector containing many objects from TCP client to the TCP server.

Code:
Vector [Students] vector = new Vector [Students] ();
Please advice me how can I do that.

- PEACE
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-02-2008, 11:34 AM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 251
roots is on a distinguished road
Code:
package one; import java.io.FileOutputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Vector; public class VectorTest { public static void main(String[] args) throws Exception { Vector<Student> vector = new Vector<Student>(); vector.add(new Student()); vector.add(new Student()); vector.add(new Student()); vector.add(new Student()); ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream( "test")); out.writeObject(vector); } } class Student implements Serializable { private static final long serialVersionUID = -135535857245815748L; private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }
Make sure that Student is Serializable and instead of FileOutputStream make it outputstream of socket. In the server side make sure it recieves the inputstream as ObjectInputStream..

Hope it helps ..
__________________
dont worry newbie, we got you covered.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending out UDP pockets Java Tip java.net 0 04-07-2008 09:07 PM
Sending Mail Using Sockets Java Tip java.net 0 04-07-2008 09:05 PM
Sending text to printer Java Tip Java Tips 0 02-04-2008 10:33 AM
sending jar files from client to server? gobinathm New To Java 2 11-13-2007 06:12 AM
Problem when sending application server with RAD 6 Marcus Advanced Java 2 07-02-2007 07:44 AM


All times are GMT +3. The time now is 10:30 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org