|
|
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.
|
|

07-24-2008, 06:51 PM
|
|
Member
|
|
Join Date: Jul 2008
Posts: 12
|
|
|
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
|
|

07-24-2008, 07:55 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
|
|
|
Is the file Read only? Or does some other app have a lock on it?
What OS?
|
|

07-25-2008, 11:51 AM
|
|
Member
|
|
Join Date: Jul 2008
Posts: 12
|
|
Originally Posted by Norm
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
|
|

07-25-2008, 12:54 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
|
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.
|
|

07-25-2008, 05:04 PM
|
|
Member
|
|
Join Date: Jul 2008
Posts: 12
|
|
|
Dear Eranga,
I think you didn't check carefully,the second true for PrintStream to on utoflush
|
|

07-25-2008, 05:40 PM
|
 |
Senior Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 187
|
|
|
you might not have the permission to write/create a file.
__________________
i am the future
|
|

07-25-2008, 05:55 PM
|
|
Member
|
|
Join Date: Jul 2008
Posts: 12
|
|
|
Hi rjual,
I already checked by already created file to specified path and also have the permission to write to that.
|
|

07-25-2008, 06:21 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
|
|
|
Is the path correct? What is the value of strFileExt?
What is your current directory relative to the path?
|
|

07-25-2008, 06:33 PM
|
|
Member
|
|
Join Date: Jul 2008
Posts: 12
|
|
|
Dear Norm,
I tried that by using by hardcoded path.
that doesn't work giving same error
__________________
Parimal
java heart
|
|

07-25-2008, 06:55 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
|
|
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?
|
|

07-25-2008, 07:10 PM
|
|
Member
|
|
Join Date: Jul 2008
Posts: 12
|
|
|
I tried all possible way like changing path or filename.
I think append flag is not matter of this problem
__________________
Parimal
java heart
|
|

07-25-2008, 08:28 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
|
|
|
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?
|
|

07-29-2008, 09:29 AM
|
|
Member
|
|
Join Date: Jul 2008
Posts: 34
|
|
|
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.
|
|

07-29-2008, 09:30 AM
|
|
Member
|
|
Join Date: Jul 2008
Posts: 34
|
|
|
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.
|
|

07-29-2008, 10:38 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
Originally Posted by jack239
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.
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.
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.
|
|

07-29-2008, 10:39 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
Originally Posted by jack239
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.
|
|

08-06-2008, 02:43 PM
|
|
Member
|
|
Join Date: Jul 2008
Posts: 12
|
|
|
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
|
|

08-06-2008, 03:27 PM
|
|
Member
|
|
Join Date: Aug 2008
Posts: 22
|
|
|
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
|
|

08-06-2008, 04:15 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
|
|
java.io.FileNotFoundException: C:\Temp\server.log (Access is denied)
I get this when the output file is flagged as R/O
|
|

08-06-2008, 05:28 PM
|
|
Member
|
|
Join Date: Jul 2008
Posts: 12
|
|
|
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
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|