Opening a large file in Java is very slow
file-io, java, large-files, nio
Solution
From the commments: To be specific, the problem is that Java's open file operation triggers the OS operation that runs the virus scan, and the solution is to add Java to the list of trusted processes
Problem
I have a large (12GB) file and I need to extract small pieces of data (a few kilobytes each) from it, using Java. Seeking and reading the data, once the file is open, is very fast, but opening the file itself takes a long time - about 90 seconds. Is there a way to speed up the open file operation in Java? To clarify, I've tried the following options to open and read a file: ``` new FileInputStream(file); new RandomAccessFile(file, "r"); Files.newByteChannel(path, StandardOpenOption.READ); ``` Each one of these yielded similar results.