You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Nicolas Maujean <nm...@hotmail.com> on 2005/08/11 19:19:16 UTC
[FtpClient] : get the size of a file
Hi,
Here is the code to get the size of a file using FtpClient using the SIZE
command of Ftp,
They have some adaptation to integrate it in FtpClient, but here you have
all the information you need to do it,
Nicolas Maujean
public class FTPClientPlus
extends FTPClient {
/**
* Constructeur
*/
public FTPClientPlus() {
super();
}
/**
* Recupere la taille du fichier
*
* @param pNomFichier
* Nom du fichier
* @return Taille du fichier
*
* @throws IOException
*/
public long getFileSize(String pNomFichier) throws IOException {
int result = sendCommand("size " + pNomFichier,
null);
if (result == 550 || result != FTPReply.FILE_STATUS) {
return -1;
}
String[] resultString = getReplyStrings();
return Long.parseLong(resultString[0].substring(4));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org