Check if a file is locked in Java December 1, 2023 by Tarik Should work in Windows: File file = new File("file.txt"); boolean fileIsNotLocked = file.renameTo(file);