R
Ramon F Herrera
How can I accomplish something like this:
% cp /dev/null somefile
in Java??
Thanks,
-Ramon
% cp /dev/null somefile
in Java??
Thanks,
-Ramon
% cp /dev/null somefile
in Java??
Vincent said: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 said: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.
Oliver said:Did you try the suggestions above? I think they would work despite this
extra specification.
- Oliver
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.