What is the best way to work with file paths in java?
The File class can be expensive enough that you don't want to use it to store every file on your hard drive in memory. I know I had problems with this, especially when I tried to use the File object tree. If you are faced with a situation where using a file class is too expensive, think about how to use Strings and convert to the files you want. But the optimization that makes your program usable is probably a sign that you have more problems. It is much more likely that the overhead associated with structure placement objects will be an issue.
source to share
The only time I know where File is using most of its memory is when you use File.list () ...
See them for some solutions:
Is there a workaround for Javas poor performance when walking around huge directories?
source to share