Hi All,

I have to send several records from Servlet to Midlet. Each record contain several data, e.g First Name, Last Name, Phone, etc. I was thinking about to choices for sending them.
First, I store the records in a text file and send to midlet. For this, in the midlet side, I have to read the file line by line, identify each field and store it locally using RMS. For this approach, I think I know how to do it.
Second, I store the record in a class and put each record in a Vector. For this one, I get stuck about how to send the vector to midlet and read it. I tried to google it and found that in the midlet side I have to deserialize the vector manually. I don't really know how to do it.
My question:
1. Which approach is more efficient in performance?
2. If the second one is more efficient, does anyone know how to send the vector and read it?
At the moment, I have this following code for the class:

PHP Code:
public class Contact {
    private 
String _firstName;
    private 
String _lastName;
    private 
String _phoneNumber;
 
    public 
Contact(){
    }
 
    public 
ContactString firstNameString lastName,
                    
String phoneNumber )
    {
        
_firstName firstName;
        
_lastName lastName;
        
_phoneNumber phoneNumber;
    }
 
    public 
String getFirstName(){
    }
 
......
 
    public 
void setPhoneNumberString number ){
    }
 
    public 
void fromByteArraybyte[] data throws IOException{
        
ByteArrayInputStream bin = new ByteArrayInputStream(data);
        
DataInputStream din = new DataInputStreambin );
 
        
_firstName din.readUTF();
        
_lastName din.readUTF();
        
_phoneNumber din.readUTF();
 
        
din.close();
    }
 
    public 
byte[] toByteArray() throws IOException {
        
ByteArrayOutputStream bout = new ByteArrayOutputStream();
        
DataOutputStream dout = new DataOutputStreambout );
 
        
dout.writeUTFgetFirstName() );
        
dout.writeUTFgetLastName() );
        
dout.writeUTFgetPhoneNumber() );
 
        
dout.close();
 
        return 
bout.toByteArray();
    } 
 

I tried to write the code in servlet for sending the vector, but I'm not sure whether it is correct or not:
PHP Code:
.....
Contact ct = new Contact();
byte[] data null;
Vector v = new Vector();
for(......){
    
ct.setFirstName(....);
    
ct.setLastName(....);
    
ct.setPhoneNumber(....);
    
data ct.toByteArray();
    
v.add(data);
}

response.setContentType("application/octet-stream");
ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream());
oos.writeObject(v);
oos.flush();
oos.close(); 
Thank you in advance.