Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-24-2008, 06:51 PM
Member
 
Join Date: Jul 2008
Posts: 12
parimal is on a distinguished road
java.io.FileNotFoundException: ..\log\server.log (Access is denied.
Hi friends,
I am getting problem while run following line:

f=new File(strFileExt);
out =new PrintStream(new BufferedOutputStream(new FileOutputStream(f,true)),true);

The error is as follows:
java.io.FileNotFoundException: ..\log\server.log (Access is denied.

)

at java.io.FileOutputStream.openAppend(Native Method)

at java.io.FileOutputStream.<init>(FileOutputStream.j ava:177)

at Test.ReadAndPrintXMLFile.main(ReadAndPrintXMLFile. java:86)


Please check out the problem

Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-24-2008, 07:55 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Norm is on a distinguished road
Is the file Read only? Or does some other app have a lock on it?
What OS?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-25-2008, 11:51 AM
Member
 
Join Date: Jul 2008
Posts: 12
parimal is on a distinguished road
Quote:
Originally Posted by Norm View Post
Is the file Read only? Or does some other app have a lock on it?
What OS?
hi Norm,
I have checked what u mentiond all ok.
file is not read only
there is no locking
Os windows-2000
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-25-2008, 12:54 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
In your BufferedOutputStream the second argument is set to true. Why is that? It should be the buffer size you going to use, so it's an int type.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-25-2008, 05:04 PM
Member
 
Join Date: Jul 2008
Posts: 12
parimal is on a distinguished road
Dear Eranga,
I think you didn't check carefully,the second true for PrintStream to on utoflush
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-25-2008, 05:40 PM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 187
rjuyal is on a distinguished road
you might not have the permission to write/create a file.
__________________
i am the future
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-25-2008, 05:55 PM
Member
 
Join Date: Jul 2008
Posts: 12
parimal is on a distinguished road
Hi rjual,
I already checked by already created file to specified path and also have the permission to write to that.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 07-25-2008, 06:21 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Norm is on a distinguished road
Is the path correct? What is the value of strFileExt?
What is your current directory relative to the path?
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 07-25-2008, 06:33 PM
Member
 
Join Date: Jul 2008
Posts: 12
parimal is on a distinguished road
Dear Norm,
I tried that by using by hardcoded path.
that doesn't work giving same error
__________________
Parimal
java heart
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 07-25-2008, 06:55 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Norm is on a distinguished road
Quote:
FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
From the API doc.
What happens if you remove the append flag?
Or change the path/filename?
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 07-25-2008, 07:10 PM
Member
 
Join Date: Jul 2008
Posts: 12
parimal is on a distinguished road
I tried all possible way like changing path or filename.
I think append flag is not matter of this problem
__________________
Parimal
java heart
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 07-25-2008, 08:28 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Norm is on a distinguished road
Have you tried it on other systems? Is there something about your environment that causes the problem?
Can you strip the code to a minimum (like 20 lines) and post it here for others to try?
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 07-29-2008, 09:29 AM
Member
 
Join Date: Jul 2008
Posts: 34
jack239 is on a distinguished road
Hi,

Use the file path as this: "c:\\temp\\myfolder\\abcd.txt"
We were having problem in one windows mahine in accessing file path when we used "c:\temp\myfolder\abcd.txt". Adding one extra slash after each solved the problems.
__________________
New to Java/PHP/Javascript development?
For free help go to-
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 07-29-2008, 09:30 AM
Member
 
Join Date: Jul 2008
Posts: 34
jack239 is on a distinguished road
Also in UNIX you should use file patha as-
"var/www/myfolder/abcd.txt' and know what Unix is very case sensitive.
__________________
New to Java/PHP/Javascript development?
For free help go to-
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #15 (permalink)  
Old 07-29-2008, 10:38 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by jack239 View Post
Hi,

Use the file path as this: "c:\\temp\\myfolder\\abcd.txt"
We were having problem in one windows mahine in accessing file path when we used "c:\temp\myfolder\abcd.txt". Adding one extra slash after each solved the problems.
Here we get an exception, use of a single slash(back slash). Because once JVM find a back slash it looking for a escape sequence. But there may not found a valid escape sequence with a single slash. To add a single slash you have to use two back slashes as follows.

Code:
c:\\temp\\myfolder\\abcd.txt
In Java this is not a good practice at all. If you use this in a UNIX/Linux system it comes with a runtime exception. Because this pattern only valid in Windows systems. So the best way is the following in Java, since it's platform independent.

Code:
c:/temp/myfolder/abcd.txt
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #16 (permalink)  
Old 07-29-2008, 10:39 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by jack239 View Post
Unix is very case sensitive.
What you try to pointed here?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #17 (permalink)  
Old 08-06-2008, 02:43 PM
Member
 
Join Date: Jul 2008
Posts: 12
parimal is on a distinguished road
strFileExt="C:\\parimal\\log\\server.log";
try
{
File f=new File(strFileExt);
out =new PrintStream(new BufferedOutputStream(new FileOutputStream(f,true)),true);

System.setOut(out);
System.setErr(out);
}catch(Exception e)
{}

But still giving like:
java.io.FileNotFoundException: C:\parimal\log\server.log (Access is denied.

)
__________________
Parimal
java heart
Bookmark Post in Technorati
Reply With Quote
  #18 (permalink)  
Old 08-06-2008, 03:27 PM
Member
 
Join Date: Aug 2008
Posts: 22
mtv134 is on a distinguished road
which OS user runs the JVM?
this user has to have the appropriate permissions on the file and the read permissions on the directory containing the file.
__________________
visit
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Muhammad Safwat
Bookmark Post in Technorati
Reply With Quote
  #19 (permalink)  
Old 08-06-2008, 04:15 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Norm is on a distinguished road
Quote:
java.io.FileNotFoundException: C:\Temp\server.log (Access is denied)
I get this when the output file is flagged as R/O
Bookmark Post in Technorati
Reply With Quote
  #20 (permalink)  
Old 08-06-2008, 05:28 PM
Member
 
Join Date: Jul 2008
Posts: 12
parimal is on a distinguished road
Dear Norm,
The problem got resolved.
Actually while i am creating a file through the file i/o that creates a folder with extention .log which is read only
__________________
Parimal
java heart
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
java.io.FileNotFoundException thevoice New To Java 5 06-13-2008 10:38 AM
SQL Server and MS Access Hima Database 0 04-08-2008 04:59 PM
java.net.SocketException: Permission denied: listen failed vitaliy Networking 2 07-09-2007 01:20 PM


All times are GMT +3. The time now is 08:43 AM.