如何将UTF-8字符串插入RecordStore并将其读取为UTF-8字符串?

谢谢

最佳答案

//write

ByteArrayOutputStream boStream = new ByteArrayOutputStream();
DataOutputStream doStream = new DataOutputStream(boStream);
doStream.writeUTF(myString);
temp.addRecord(boStream.toByteArray(), 0, boStream.size());




//read

ByteArrayInputStream biStream = new ByteArrayInputStream(temp.getRecord(id));
DataInputStream diStream = new DataInputStream(biStream);
myString = diStream.readUTF();

07-27 23:07