Shm*_*yễn 4 java inputstream file-handling
如何为使用 java InputStream API 创建和写入的文件设置只读访问权限。
小智 5
在我看来,最好先检查文件是否已创建或存在,然后设置只读标志。
File file = new File("C:/path/file.txt");
if (file.exists()) {
file.setReadOnly();
} else {
System.out.println("File does not exists.");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4071 次 |
| 最近记录: |