未知的解析器类型

未知的解析器类型

本文介绍了org.apache.commons.net.ftp.parser.ParserInitializationException:未知的解析器类型:Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图连接到Linux上的FTP服务器,当我执行 ftp.listFiles(remote);

I am trying to connect to FTP server which is on Linux, I am getting below exception when I execute ftp.listFiles(remote);

SYST 215  Linux  Exception in thread "AWT-EventQueue-0"
org.apache.commons.net.ftp.parser.ParserInitializationException:
Unknown parser type:  Linux     at
org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createFileEntryParser(DefaultFTPFileEntryParserFactory.java:165)
at
org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createFileEntryParser(DefaultFTPFileEntryParserFactory.java:94)
at
org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:3192)
at
org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2857)

当我连接到Windows上的FTP服务器时,相同的代码可以正常工作.

The same code is working fine when I connect to FTP server which is on Windows.

我搜索了它的解决方案,但我猜没有人会遇到linux这样的问题.在这里找到了一篇推荐使用 listNames()而不是 listfiles()的帖子,但这也无法解决其他错误.

I searched for the solution of it but I guess no one has faced such issue with linux. Found one post here which recommends to use listNames() instead listfiles() but that too is not working with different error.

请帮助.

推荐答案

FTPClient ftp = new FTPClient()
ftp.configure(new FTPClientConfig(FTPClientConfig.SYST_UNIX));

尝试设置 FTPCientConfig与您的系统匹配.

Try setting an FTPCientConfig that matches your system.

这篇关于org.apache.commons.net.ftp.parser.ParserInitializationException:未知的解析器类型:Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 10:41