I am writing to a file using RandomAccessFile.The data(fields) are stored in fixed field length,e.g every field would alloted space of 16 bytes.I write something by placing the pointer to the appropriate position using seek(). Problem comes when I overwrite some fields,i.e,if "Bangalore" was stored earlier and if overwrite it with "Delhi" the result is "Delhilore". How do I erase "Bangalore" completely prior to writing "Delhi"?
If value is the String I want to write and length is the fixed field length(16)
byte[] b=new byte[length];
b=value.getBytes();
try
{
database.seek(offset);
database.write(b);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}