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.
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.