List of usage examples for org.apache.commons.net.ftp FTPCmd LIST
FTPCmd LIST
To view the source code for org.apache.commons.net.ftp FTPCmd LIST.
Click Source Link
From source file:com.adaptris.ftp.ApacheFtpClientImpl.java
/** * list files in the current server directory *//*from w ww .j a v a2 s.c om*/ @Override public String[] dir(String dirname, boolean full) throws IOException { String[] listing = new String[0]; try { acquireLock(); log("{} {}", FTPCmd.LIST, dirname); FTPFile[] results = ftpClient().listFiles(dirname); logReply(ftpClient().getReplyStrings()); List<String> output = new ArrayList<String>(); for (FTPFile file : results) { if (full) { output.add(file.toFormattedString()); } else { output.add(file.getName()); } listing = output.toArray(new String[output.size()]); } } finally { releaseLock(); } return listing; }
From source file:com.atomicleopard.thundr.ftp.commons.FTP.java
/*** * A convenience method to send the FTP LIST command to the server, * receive the reply, and return the reply code. Remember, it is up * to you to manage the data connection. If you don't need this low * level of access, use {@link org.apache.commons.net.ftp.FTPClient} * , which will handle all low level details for you. * <p>/*from w w w. j ava 2 s. c o m*/ * @return The reply code received from the server. * @exception FTPConnectionClosedException * If the FTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send FTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int list() throws IOException { return sendCommand(FTPCmd.LIST); }
From source file:com.atomicleopard.thundr.ftp.commons.FTP.java
/*** * A convenience method to send the FTP LIST command to the server, * receive the reply, and return the reply code. Remember, it is up * to you to manage the data connection. If you don't need this low * level of access, use {@link org.apache.commons.net.ftp.FTPClient} * , which will handle all low level details for you. * <p>/*from w w w. j a v a 2 s . c o m*/ * @param pathname The pathname to list, * may be {@code null} in which case the command is sent with no parameters * @return The reply code received from the server. * @exception FTPConnectionClosedException * If the FTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send FTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int list(String pathname) throws IOException { return sendCommand(FTPCmd.LIST, pathname); }
From source file:com.atomicleopard.thundr.ftp.commons.FTPClient.java
/** * private method through which all listFiles() and * initiateListParsing methods pass once a parser is determined. * * @exception FTPConnectionClosedException * If the FTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send FTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @exception IOException//ww w.j a v a 2 s.c o m * If an I/O error occurs while either sending a * command to the server or receiving a reply from the server. * @see FTPListParseEngine */ private FTPListParseEngine initiateListParsing(FTPFileEntryParser parser, String pathname) throws IOException { Socket socket = _openDataConnection_(FTPCmd.LIST, getListArguments(pathname)); FTPListParseEngine engine = new FTPListParseEngine(parser); if (socket == null) { return engine; } try { engine.readServerList(socket.getInputStream(), getControlEncoding()); } finally { Util.closeQuietly(socket); } completePendingCommand(); return engine; }