I have to copy images (4-6 MB each) periodically (each 8 seconds) into one folder. When a files count in the target folder reaches circa 320 files, an error is thrown. And if I restart an application, another circa 320 files are copied before an error is thrown again (so it is independent on a files count in a target directory):
java.nio.file.FileSystemException: X:\src\from.jpg -> X:\target\to.jpg: Not enough storage is available to process this command at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) at sun.nio.fs.WindowsFileCopy.copy(WindowsFileCopy.java:205) at sun.nio.fs.WindowsFileSystemProvider.copy(WindowsFileSystemProvider.java:278) at java.nio.file.Files.copy(Files.java:1274)
I'm using Files.copy(f.toPath(), t.toPath())
to copy the file.
I think a problem si related to System Error. Code: 8. Not enough storage is available to process this command .
Is it possible to somehow clean used resources to avoid this Exception?