问题描述
- ftpsclient 的listfiles返回值为空
-
public boolean ftptest(String server,String userName,String passWord){ final int dataTimeout = 5000; X509TrustManager x509m = new X509TrustManager() { @Override public X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { } @Override public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { } }; SSLContext sslcontext = SSLContext.getInstance("SSL"); sslcontext.init(null, new TrustManager[] { x509m }, new java.security.SecureRandom()); FTPSClient ftpsClient = new FTPSClient(false,sslcontext); try { ftpsClient.connect(server,21); boolean iflogin = ftpsClient.login(userName, passWord); ftpsClient.enterLocalPassiveMode(); ftpsClient.setDataTimeout(dataTimeout); FTPFile[] listFiles = ftpsClient.listFiles();//listFiles 为空 String[] listNames = ftpsClient.listNames();//listNames 为空 if(listNames==null){ System.out.println("结果为空"); } ftpsClient.logout(); ftpsClient.disconnect(); } catch (SocketException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
解决方案
看了你的问题描述,找到一篇相同问题的文章,http://qdpurple.iteye.com/blog/855120。
祝好!
解决方案二:
嗯,谢谢,但是还是解决不了
时间: 2025-01-23 14:49:07