Files.copy java.nio.file.AccessDeniedException

I want to copy into my local folder the directories and files in each directory through http.

I have run the following Java codes and the error message as below comes up.

How can i address this problem?

boolean getLogfilesFromURL(String inFileFolder, String URLRemote  ) throws MalformedURLException, IOException{
             Path path = Paths.get(inFileFolder );
                       URI u = URI.create(URLRemote);//"http://java.sun.com/");
                       try (InputStream in = u.toURL().openStream()) {
                         Files.copy(in, path);
                       }
                        
            return true;            
      }
java.nio.file.AccessDeniedException: data
      at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
      at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
      at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
      at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(Unknown Source)
      at java.nio.file.spi.FileSystemProvider.newOutputStream(Unknown Source)
      at java.nio.file.Files.newOutputStream(Unknown Source)
      at java.nio.file.Files.copy(Unknown Source)
      at data_management.ImportDataFromURLToEnTrak.getLogfilesFromURL(ImportDataFromURLToEnTrak.java:65)
      at data_management.ImportDataFromURLToEnTrak.main(ImportDataFromURLToEnTrak.java:668)
e-genpartnersAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
I want to copy into my local folder the directories and files in each directory through http.
That's not what your code will do. At best (if it works) it will copy the content of the web page you're reading to a file named by the Paths.get parameter
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
e-genpartnersAuthor Commented:
Is there any way to copy all files and directories over the HTTP(or FTP) into my local folder?
I am looking for an auotomatic process to copy whole files from the remote source to my local folder as they are.

Thanks.
0
CEHJCommented:
There's no reliable way with http unless the web server has listing turned on (and then you've still work to do)

If ftp is supported on the server, that's another issue. You'd then use an ftp api for Java
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

e-genpartnersAuthor Commented:
It is very helpful.
Do you have recommendable sample codes with the FTP API ?
0
CEHJCommented:
with the FTP API ?
Which ftp api? It will generally be with whatever you use
0
CEHJCommented:
:)

Apache Commons Net is often used for ftp

http://commons.apache.org/proper/commons-net/
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.