View Single Post
  #2 (permalink)  
Old 01-02-2008, 11:34 AM
roots's Avatar
roots roots is offline
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 258
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.
Reply With Quote