[英]File not being created in root directory
I am getting this error 我收到此错误
Exception in thread "main" java.io.IOException: Access is denied at java.io.WinNTFileSystem.createFileExclusively(Native Method) at java.io.File.createNewFile(Unknown Source)
here is the code, I get that exception after I hit the createNewFile line.. 这是代码,在单击createNewFile行后得到该异常。
`
//ELSE Creating the new file
String fileName = userName + ".usr";
File f = new File("C:/", fileName);
f.createNewFile(); }`
Try to create the file yourself. 尝试自己创建文件。 Most new windows os prevent writing to root c without elevated permissions.
大多数新的Windows操作系统都会阻止在没有提升权限的情况下写入root c。 If you cant create it manually without special permissions same goes to your code.
如果您无法在没有特殊权限的情况下手动创建它,则代码也会进入。
createNewFile()
method throws IOException
. createNewFile()
方法抛出IOException
。 You should handle the exception. 您应该处理异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.