Java, IO - fastest way to remove file

Viewed 17860

My problem is that I have an app which is writing a lot of relatively (100-500kb) small CSV files (tens and hundreds of thousands ). Content of those files then get loaded in database via sql loader call (its oracle db) and this is what I have to live with.

So, I need to remove those small files time to time to prevent them from eating up all space. I would like to attach that to the activity which writes those files and loads them into db as a last finalize step.

My Question is -- how in java can one remove a bunch of small files with less overhead on performance?

Thanks in advance! Michael

5 Answers

One can you use java.nio.file.Files's below method

delete(Path path)
deleteIfExists(Path path)

For more information refer this article

Related