Reputation: 57
My development PC was having hardware problems, so I copied my source program code (Netbeans java) and loaded it into a backup laptop. When my desktop pc failed, I went to my backup laptop, to recreate my project. Everything worked basically except the source code I copied did not have some library modules as well as some other unknown modules. I got one program to work by loading the required library module in Netbeans, however one of the other programs is failing with the following error:
java.io.FileNotFoundException: C:\aaageing.txt (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
at java.io.FileOutputStream.<init>(FileOutputStream.java:165)
at my.TTjav.TTjavAgeing.main(TTjavAgeing.java:34)
Exception in thread "main" java.lang.NullPointerException
at java.io.Writer.<init>(Writer.java:88)
at java.io.OutputStreamWriter.<init>(OutputStreamWriter.java:109)
at java.io.PrintWriter.<init>(PrintWriter.java:148)
at java.io.PrintWriter.<init>(PrintWriter.java:131)
at my.TTjav.TTjavAgeing.main(TTjavAgeing.java:38)
and I'm not sure which library modules or?? I need.
I am using the following:
File outFile = new File("C:\\aaageing.txt");
FileOutputStream outFileStream = null;
try {
outFileStream = new FileOutputStream(outFile);
} catch (FileNotFoundException ex) {
Logger.getLogger(TTjavAgeing.class.getName()).log(Level.SEVERE, null, ex);
}
PrintWriter outStream = new PrintWriter(outFileStream);
Upvotes: 1
Views: 315
Reputation: 29150
As you are getting "Access is denied
", then you need to give permission.
aaageing.txt
in C drive,Properties
, and go to Security tab
.Advanced button
(shown in the link).Edit
button.http://www.addictivetips.com/windows-tips/windows-7-access-denied-permission-ownership/
After that it will run smoothly.
Upvotes: 2
Reputation: 81
check the file C:\aaageing.txt
if exists run like administrator or change permission of the file
Upvotes: 2
Reputation: 13793
Your stacktrace is telling you everything you are asking about.
java.io.FileNotFoundException: C:\aaageing.txt (Access is denied)
It seems like you do not have required access rights to get to that file. Try running as an administrator.
Upvotes: 1