2013-02-27 44 views
0

在Windows上的Java中,我們如何知道文件或文件夾是讀保護的?我們如何知道文件被讀取保護?

我試着用的CanRead()等setReadable():

String pathFile = "D:/Folder"; 
File f = new File(pathFile); 
System.out.println("Is Protected => " + f.setReadable(true)==true); 

,但它不解決我的問題

謝謝

+3

您能否澄清canRead()如何解決您的問題? – eis 2013-02-27 15:44:12

回答

0

canWrite方法是真,當且僅當文件系統實際包含由此抽象路徑名錶示的文件,並允許應用程序寫入文件;否則爲假。

File lFile = new File("Sample.txt") 
lFile.canWrite(); 
+0

我說的是文件或文件夾的canRead()是被讀保護的 – mkodad 2013-02-27 15:54:48

+0

對於一個文件,你可能會使用這個文件或文件夾(「d:\\ test2.txt」);如果(lFile.exists())System.out.println(「is ReadOnly =」+!lFile.canWrite());' } – Prabhu 2013-02-27 16:07:45

+0

why!lFile.canWrite()? – mkodad 2013-02-27 16:10:18

相關問題