Search code examples
javafileionio

Java, IO - fastest way to remove file


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


Solution

  • Well, file.delete() should suffice (it is internally implemented as a native method)