When I'm running the following portion of code in Windows (in Linux I don't get this type of error), I get the java.io.IOException in the title. How can I resolve this issue? Thanks
RandomAccessFile randomAccessFile = null;
try {
randomAccessFile = new RandomAccessFile(fileToAccess, "rw");
} catch (FileNotFoundException e) {
e.printStackTrace();
System.exit(-1);
}
FileChannel outChannel = randomAccessFile.getChannel();
try (outChannel; FileLock fileLock = outChannel.lock()) {
FileManagement fileManagement = new FileManagement();
Path path = Paths.get(fileToAccess);
List<String> lines = Files.readAllLines(path, StandardCharsets.UTF_8);
fileLock.release();
} catch (OverlappingFileLockException | IOException ex) {
System.err.println("Exception occured while trying to get a lock on File... " + ex.getMessage());
System.exit(-1);
}