Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

(Access is denied) error

Could anyone please tell me why am I getting the error "C:\temp\Installation (Access is denied)".
I am trying to copy selected few files from source to destination.

public class filesMove
{
public filesMove()
{
}

void copyDirectory(File source, File destination) throws IOException
{
System.out.println("source: "+source);
//output: source: D:\fonts\xyz.PFB
//output: source: D:\fonts\xyz.PFM

System.out.println("destination:"+destination);
//output: destination: C:\temp\Installation

copyFile(source, destination);
}

private void copyFile(File src, File dst) throws IOException
{
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);
byte[] buf = new byte[1024];
int len;
while((len = in.read(buf)) > 0)
{
out.write(buf, 0, len);
}
in.close();
out.close();
}
}
[999 byte] By [sony_tj] at [2007-11-11 10:03:56]
# 1 Re: (Access is denied) error
if you running on Unix box, check the permission. you should have write permission for the directory C:\temp\Installation and read permission for the files you are copying..(make sure that java is running with the same user)
in Windows i don't know how to resolve . :(
sudheerprem at 2007-11-11 22:32:01 >
# 2 Re: (Access is denied) error
I have access to "C:\temp\Installation" and also read and write permission. I think there is some problem with my code
sony_tj at 2007-11-11 22:33:06 >
# 3 Re: (Access is denied) error
http://forum.java.sun.com/thread.jspa?threadID=5118440
prometheuzz at 2007-11-11 22:34:05 >
# 4 Re: (Access is denied) error
Thanks my problem is solved
sony_tj at 2007-11-11 22:35:04 >