Results 1 to 2 of 2
Thread: Sending a Vector to TCP server
- 12-30-2007, 12:34 PM #1
Member
- Join Date
- Dec 2007
- Posts
- 49
- Rep Power
- 0
- 01-02-2008, 10:34 AM #2
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..Java 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; } }
Hope it helps ..dont worry newbie, we got you covered.
Similar Threads
-
Sending text to printer
By Java Tip in forum Java TipReplies: 1Last Post: 05-25-2009, 06:14 AM -
Sending out UDP pockets
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 08:07 PM -
Sending Mail Using Sockets
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 08:05 PM -
sending jar files from client to server?
By gobinathm in forum New To JavaReplies: 2Last Post: 11-13-2007, 05:12 AM -
Problem when sending application server with RAD 6
By Marcus in forum Advanced JavaReplies: 2Last Post: 07-02-2007, 06:44 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks