0
i utilisé CrossFTP pour créer un serveur FTP Apache commons ftp
quand je connecté en utilisant Firefox, il fonctionne bien.
mais en utilisant Apache commons, il renvoie une exception
import java.net.SocketException;
import org.apache.commons.net.ftp.FTPClient;
import java.io.IOException;
public class FtpConnectDemo {
public static void main(String[] args) throws SocketException, IOException {
FTPClient client = new FTPClient();
client.connect("ftp://192.168.1.150");
boolean login = client.login("ehab01", "CD7IZW0O");
if (login) {
System.out.println("Login success...");
boolean logout = client.logout();
if (logout) {
System.out.println("Logout from FTP server...");
}
} else {
System.out.println("Login fail...");
}
client.disconnect();
}
}
Exception in thread "main" java.net.UnknownHostException: ftp://192.168.1.150
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:849)
at java.net.InetAddress.getAddressFromNameService(InetAddress.java:1200)
at java.net.InetAddress.getAllByName0(InetAddress.java:1153)
at java.net.InetAddress.getAllByName(InetAddress.java:1083)
at java.net.InetAddress.getAllByName(InetAddress.java:1019)
at java.net.InetAddress.getByName(InetAddress.java:969)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:184)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:273)
at com.ftp.FtpConnectDemo.main(FtpConnectDemo.java:19)
cela fonctionne bien merci. –