I was wondering what is the point of only having static methods in FileUtils? Is there a reason not to have instance methods? I believe FileUtils is thread-safe (Correct me if I am wrong lol), but I do have a bunch of threads using the FileUtils methods at the same time, and it seems like having multiple instances would work better than having synchronized code. Is there a library that mimics the FileUtils library, but does not contain any static methods?
Share
Because
FileUtilsis a collection of stateless methods. It wouldn’t make sense to introduce an object for it – what would it contain?It all depends on what and how you’re trying to achieve sth. If you e.g. try to read from multiple or even the same file in multiple threads it’ll work fine. However if you try e.g. to write to the same file from within multiple threads you may have some problems. These problems will stem however from the fact that you’re using the same file for writing things and thus do not actually make
FileUtilsnot thread-safe.