I'd like to instantiate a file from an FTP path like:
java.io.File file = new File("ftp://"+"path/to/file");
But when I try to get the fileInputStream of this file:
FileInputStream in = new FileInputStream(file);
I get a java.io.FileNotFoundException.
When I debug, I can see that during the instantiation of the file object, the path turns to "ftp:/path/to/file" -- with ONE slash ==> which throws the exception since he needs double slashes "//" after "ftp:" to locate the file into the FTP server.
How can I make the path contain double slashes ?
Thank you
You need to use a FTP client, such as Apache Commons Net .
The File API available in the JDK cannot connect to a FTP server out of the box.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.