wood burning stoves*
The moose likes General Computing and the fly likes java.io.WinNTFileSystem.createFileExclusively Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "java.io.WinNTFileSystem.createFileExclusively" Watch "java.io.WinNTFileSystem.createFileExclusively" New topic
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: 19651
    
  18

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 - OCEEJBD 6
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: 10167
    
    8

If you can answer Rob's question, it will throw some light on the problem


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37936
    
  22
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: java.io.WinNTFileSystem.createFileExclusively
 
Similar Threads
Compare datas
File I/O R/W + Permission Issue
java.io.IOException: CreateProcess: error=2
Iterating through a String.