> How can I accomplish something like this:
>
> % cp /dev/null somefile
>
> in Java??
RandomAccessFile raf = new RandomAccessFile("somefile", "rw");
raf.setLength(0);
raf.close();
or
(new FileOutputStream("somefile")).close();
or
File f = new File("somefile");
if (f.exists()) {
f.delete();
}
f.createNewFile();
Vincent
Ramon F Herrera - 28 Jul 2006 21:00 GMT
> > How can I accomplish something like this:
> >
[quoted text clipped - 19 lines]
>
> Vincent
Vince:
Thanks for your answer. I should have specified that the file
"somefile" already exists but I don't care about its contents, I just
need to empty it.
-Ramon
Oliver Wong - 28 Jul 2006 21:51 GMT
>> > How can I accomplish something like this:
>> >
[quoted text clipped - 25 lines]
> "somefile" already exists but I don't care about its contents, I just
> need to empty it.
Did you try the suggestions above? I think they would work despite this
extra specification.
- Oliver
Ramon F Herrera - 29 Jul 2006 02:35 GMT
> >> > How can I accomplish something like this:
> >> >
[quoted text clipped - 30 lines]
>
> - Oliver
Yes, I tried them, and they work as expected.
Thanks!
-Ramon