reading two strings from rms

hi guys i save two strings in the same array of bytes in this way:

baos =new ByteArrayOutputStream();

dos =new DataOutputStream(baos);

dos.writeChars(id);

dos.writeChars(dire);

System.out.println(id);

System.out.println(dire);

dos.flush();

registro = baos.toByteArray();

rs.addRecord(registro,0,registro.length);

baos.close();

dos.close();

and i read them like this:

ByteArrayInputStream bais;

String x, y;

DataInputStream dis;

byte[] registro =newbyte[75];

try{

bais =new ByteArrayInputStream(registro);

dis =new DataInputStream(bais);

System.out.println("numero de registros: " + rs.getNumRecords());

for (int i=1;i<=rs.getNumRecords();i++){

rs.getRecord(i,registro,0);

x = dis.readUTF();

LectArch.append("Numero de Id: " + x,null);

LectArch.append("Direcci髇: ",null);

y = dis.readUTF();

LectArch.append(y,null);

bais.reset();

System.out.println(x + y);

}

bais.close();

dis.close();

rs.closeRecordStore();

}

this works excelent when i save two drifferents types of values like int and string but doesnt work with two string, is it wrong to try to save two string in the same array?

[1920 byte] By [eckoa] at [2007-11-27 6:12:15]
# 1
use writeUTF() and readUTF()
rashidmayesa at 2007-7-12 17:19:19 > top of Java-index,Java Mobility Forums,Java ME Technologies...