问题
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)
The same code is working fine when I connect to FTP server which is on Windows.
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.
Please help.
回答1:
FTPClient ftp = new FTPClient()
ftp.configure(new FTPClientConfig(FTPClientConfig.SYST_UNIX));
Try setting an FTPCientConfig that matches your system.
来源:https://stackoverflow.com/questions/16009094/org-apache-commons-net-ftp-parser-parserinitializationexception-unknown-parser