• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

java.io.WinNTFileSystem.createFileExclusively

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Sheriff
Posts: 22656
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you create files in D: from other programs? You may simply have no rights to write to that folder.
 
Jalli Venkat
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can answer Rob's question, it will throw some light on the problem
 
Marshal
Posts: 75857
361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doesn't sound like a "beginning Java" question. Moving to "general computing."
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)






 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic