java me: How to clear a file

file, java-me

Solution

Call your write() method like this:

.write((new String()).getBytes());

This will make your file empty.

You can also delete your file and create a new one. This will also results into an empty file having the same file name.

Problem

How to clear a file in J2ME so that it becomes empty (no content)? All output streams (`OutputStream, DataOutputStream, PrintStream...`) can only `write()` and add the content to the file while I see no way to delete a byte/bytes in a file. I use Netbeams 7.0.1 Thanks for any help

Original source