As a guess, the ftp server may be using an ascii connection for some (or all) files. One way to test this is to use ftp manually, and set the connection to ascii by typing "type=ascii" before transferring. Compare the file you get this way with the file you get from your program - are the bytes identical? Are they corrupted exactly the same way? Now set type=binary and try again. Is the file OK this time? No corruption? If the answer to all these questions is yes, then your problem is indeed an ascii connection. I'd think there should be a way to specify a binary transfer using the URL class - as I read the specs for URLs, it should be possible using something like URL url = new URL("ftp://user email@example.com/dir/file.ext;type=I"); However I can't get this to actually work - I keep getting FileNotFoundException for filename "file.ext;type=I". So I'm not sure if I'm doing something wrong, or Java just doesn't support this. Does anyone else know? There is an Java FTP client library someone put together, available from GNU. You can always try using that, and/or study it for ideas. Good luck - and please let us know if you get a solution.
My guess would be the semicolon should be a question mark in that url: URL url = new URL("ftp://user:firstname.lastname@example.org/dir/file.ext?type=I"); [ February 05, 2002: Message edited by: Steve Deadsea ]
Joined: Jan 30, 2000
Yeah, that does it, thanks. I should have thought to try that - I was foolishly believing that a document on URLs from w3.org might actually be relevant. Urg. Are there rules written down somewhere which are actually used, or does everyone make it up as they go? :roll: