java - How to create a commons-net FTPClient from a URL -
is there way construct ftpclient instance url such ftp://user:pass@foo.bar:2121/path
, similar ftpurlconnection in jdk?
if problem parsing use code below parse , create wrapper class ...
import java.net.; import java.io.;
public class parseurl {
public static void main(string[] args) throws exception {
url aurl = new url("http://java.sun.com:80/docs/books/tutorial"
+ "/index.html?name=networking#downloading");
system.out.println("protocol = " + aurl.getprotocol());
system.out.println("authority = " +
aurl.getauthority());
system.out.println("host = " + aurl.gethost());
system.out.println("port = " + aurl.getport());
system.out.println("path = " + aurl.getpath());
system.out.println("query = " + aurl.getquery());
system.out.println("filename = " + aurl.getfile());
system.out.println("ref = " + aurl.getref());
} }
here's output displayed program:
protocol = http
authority = java.sun.com:80
host = java.sun.com
port = 80
path = /docs/books/tutorial/index.html
query = name=networking
filename = /docs/books/tutorial/index.html?name=networking
ref = downloading
Comments
Post a Comment