| Author |
java.io.WinNTFileSystem.createFileExclusively
|
Jalli Venkat
Greenhorn
Joined: Aug 10, 2006
Posts: 27
|
|
Check for existence==>false
java.io.IOException: Access is denied
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(Unknown Source)
at FileIO1.main(FileIO1.java:13)
Check for existence==>false
When I trying to run following code
File f1 = new File("D:\\TestFile.txt");
System.out.println("Check for existence==>"+f1.exists());
try {
f1.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I getting above error message about "java.io.IOException: Access is denied". Can anybody help me in this?
|
venkat
|
 |
Chinna Eranna
Ranch Hand
Joined: Dec 08, 2009
Posts: 174
|
|
do you see any security manager related strings in the exception trace..
like.. at java.lang.SecurityManager.checkPermission
Can you post the complete exception traces ?
|
- Chinna
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Can you create files in D: from other programs? You may simply have no rights to write to that folder.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Jalli Venkat
Greenhorn
Joined: Aug 10, 2006
Posts: 27
|
|
No i didnt get any security related messages, below is the message coming after compilation of program
java.io.IOException: Access is denied
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(Unknown Source)
at FileIO1.main(FileIO1.java:13)
Check for existence==>false
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8433
|
|
|
If you can answer Rob's question, it will throw some light on the problem
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32627
|
|
|
Doesn't sound like a "beginning Java" question. Moving to "general computing."
|
 |
Mohammad Taslim
Greenhorn
Joined: Aug 25, 2011
Posts: 1
|
|
Taslim(From Pune)-
This might help you:-
If You have folder structure:-
C:\temp\File.java
And you are trying to create a new file (named same as the folder name File.java) at the same location C:\temp\
File myFile = new File("C://temp/" , "File.java");
myFile.createNewFile();
It will throw you this error:-
C:\temp\File.java
java.io.IOException: Access is denied
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:850)
at com.java.InputOutput.file.FileMainClass.filenamepath(FileMainClass.java:23)
at com.java.InputOutput.file.FileMainClass.main(FileMainClass.java:55)
|
 |
Nafis Akhtar
Greenhorn
Joined: Apr 08, 2012
Posts: 1
|
|
try{
boolean isCreated = false;
File file = new File("D:\\myFile.txt ");
System.out.println(file.exists());
isCreated = file.createNewFile();
System.out.println(isCreated);
System.out.println(file.exists());
}catch(IOException e){
e.printStackTrace();
}
Hope it will work.
|
 |
 |
|
|
subject: java.io.WinNTFileSystem.createFileExclusively
|
|
|