addRecord hangs

Hi,

addRecord hangs during the call

The code is as follow:

public void updateRecord(String record) {

if(record != null)

{

ByteArrayOutputStream baos = new ByteArrayOutputStream();

DataOutputStream outputStream = new DataOutputStream(baos);

try{

outputStream.writeUTF(record);

}catch (IOException ioe) {

System.out.println(ioe);

}

byte[] recordByte = baos.toByteArray();

try{

myRecordStore.addRecord(recordByte, 0, recordByte.length);

}catch(RecordStoreException rse){

System.err.println(rse.toString());

}

}

}

When I trace the code, it get stuck on "addRecord" call and never comes out.

Note that the RecordStore is already open and also the values all seem to be valid during debug.

any help will be much appreciated.

Thanks,

S.

[888 byte] By [sasanplusa] at [2007-10-3 3:17:50]
# 1
Hi S.The code seems to be correct.Does the error happen on emulator or device?If on device, check the available space to the current record store by call to getSizeAvailable(). (Returns the available space in bytes.)bye,Asghar
Asghara at 2007-7-14 21:09:28 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

>public void updateRecord(String record) {

>if(record != null)

>{

> ByteArrayOutputStream baos = new

> ByteArrayOutputStream();

> DataOutputStream outputStream = new

> DataOutputStream(baos);

>

> try{

>outputStream.writeUTF(record);

///here close output Stream

outputStream.close();

> }catch (IOException ioe) {

> System.out.println(ioe);

>}

>byte[] recordByte = baos.toByteArray();

also check if recordByte !=null

>try{

> myRecordStore.addRecord(recordByte, 0,

> recordByte.length);

>}catch(RecordStoreException rse){

>System.err.println(rse.toString());

>}

> }

>}

> hen I trace the code, it get stuck on "addRecord"

> call and never comes out.

>

> Note that the RecordStore is already open and also

> the values all seem to be valid during debug.

>

> any help will be much appreciated.

>

> Thanks,

> S.

sailesh_dita at 2007-7-14 21:09:28 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
well I actually found the problem before by checking of the recordStore is null before addRecord and I got to the point of failure.but Thanks anywaysSasan
sasanplusa at 2007-7-14 21:09:28 > top of Java-index,Java Mobility Forums,Java ME Technologies...