Tim Moores wrote:Why are you trying to reinvent the wheel? That's what Rsync does, not the WebDAV part, but the file syncing part.
Are both WebDAV servers in place? Do you have their URLs, usernames and passwords?
The Java class libraries do not have a WebDAV client, but searching for "java webdav library" or some such term will find several.
----------------------------------------------------------------------------------------
sorry for the late reply.
Since I am learning I kind of want to do it from scratch, and we are just working on one server where we have two folders. We just need to update one from the other and I have the user name and password. I am able to connect and get the entire file system the only part I am having trouble now is with copying a file from one folder to another. The below code works perfectly the first time but when it finds a second file that needs to copied it throws an exception.
This is the console:
reading before inp: /filesys1/Copy (2)/Copy (2) (3)/doc - Copy (2) (3) 3 - Copy.txt
reading after inp: null/doc - Copy (2) (3) 3 - Copy.txt
write success: true, /filesys2/Copy (2)/Copy (2) (3)/doc - Copy (2) (3) 3 - Copy.txt
reading before inp: /filesys1/Copy (2)/Copy (2) (3)/doc - Copy (2) (3) 4 - Copy.txt
reading after inp: null/doc - Copy (2) (3) 4 - Copy.txt
Exception in
thread "main" java.lang.NullPointerException
at org.apache.commons.net.io.Util.copyStream(Util.java:100)
at org.apache.commons.net.ftp.FTPClient.__storeFile(FTPClient.java:385)
at org.apache.commons.net.ftp.FTPClient.storeFile(FTPClient.java:1379)
at FtpConnectTry.gotoDirectory(FtpConnectTry.java:12)
at FtpConnectTry.gotoDirectory(FtpConnectTry.java:89) //the only code line 89 has is a recursive call to he method
at FtpConnectTry.gotoDirectory(FtpConnectTry.java:89) //the only code line 89 has is a recursive call to he method
at FtpConnectTry.main(FtpConnectTry.java:34) //the only code line 34 has is a recursive call to he method
Also notice how it returns null in the console after the inputStream inp = new.....
Say if there are 20 files that need to be copied from source to destination my program will do exactly what it needs to if we run it 20 times, so again the problem is whenever we come into this if loop the second time it gives an error. any suggestions will be greatly appreciated.