I am making an application that includes file copying, but when I go through a large directory (1000+) files and copy them to another folder, it uses 290+ MB of RAM.
So, is there any way to change the File
of FileOutputStream
without creating a new instance of the FileOutoutStream
class?
EDIT:
Here is my Java 7 API version.
Path source = FileSystems.getDefault().getPath(Drive.getAbsolutePath(), files[i].getName());
Path destination = FileSystems.getDefault().getPath(Save);
try {
Files.copy(source, destination);
} catch (FileAlreadyExistsException e) {
File file = new File(Save + files[i]);
file.delete();
}
Keep in mind, that this is in a for loop that is being tested on 1000+ file counts. With the current method I am using 270+ MB of RAM