Если вы не запустите свое приложение Java в качестве администратора, у вас не будет доступа на запись к C:
.
Следующий код
public static void main(String[] args) throws Exception {
RandomAccessFile file1 = new RandomAccessFile("C:\\lol.txt", "rw");
}
даст вам
Exception in thread "main" java.io.FileNotFoundException: C:\lol.txt (Access is denied)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(Unknown Source)
at java.io.RandomAccessFile.<init>(Unknown Source)
at Test.Main.main(Main.java:79)
The javadoc для RandomAccessFile
конструктора состояний это:
FileNotFoundException - if the mode is "r" but the given string does not denote an existing regular file, or if the mode begins with "rw" but the given string does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file
Просто переместите файл в другое место, как C:\Users\You
.
У вас есть разрешение на запись в файл? –
У вас есть право на капитализацию? – rolfl
Да, у меня есть разрешение, и капитализация верна. –