public long fileSize(String path) throws IllegalStateException, IOException, FTPIllegalReplyException, FTPException {
synchronized (lock) {
    if (!connected) {
      throw new IllegalStateException("Client not connected");
    }
    if (!authenticated) {
      throw new IllegalStateException("Client not authenticated");
    }
    communication.sendFTPCommand("TYPE I");
    FTPReply r=communication.readFTPReply();
    touchAutoNoopTimer();
    if (!r.isSuccessCode()) {
      throw new FTPException(r);
    }
    communication.sendFTPCommand("SIZE " + path);
    r=communication.readFTPReply();
    touchAutoNoopTimer();
    if (!r.isSuccessCode()) {
      throw new FTPException(r);
    }
    String[] messages=r.getMessages();
    if (messages.length != 1) {
      throw new FTPIllegalReplyException();
    }
 else {
      try {
        return Long.parseLong(messages[0]);
      }
 catch (      Throwable t) {
        throw new FTPIllegalReplyException();
      }
    }
  }
}

public long fileSize ( String path ) throws IllegalStateException , IOException , FTPIllegalReplyException , FTPException { synchronized ( lock ) { if ( ! connected ) { throw new IllegalStateException ( "Client not connected" ) ; } if ( ! authenticated ) { throw new IllegalStateException ( "Client not authenticated" ) ; } communication . sendFTPCommand ( "TYPE I" ) ; FTPReply r = communication . readFTPReply ( ) ; touchAutoNoopTimer ( ) ; if ( ! r . isSuccessCode ( ) ) { throw new FTPException ( r ) ; } communication . sendFTPCommand ( "SIZE " + path ) ; r = communication . readFTPReply ( ) ; touchAutoNoopTimer ( ) ; if ( ! r . isSuccessCode ( ) ) { throw new FTPException ( r ) ; } String [ ] messages = r . getMessages ( ) ; if ( messages . length != 1 ) { throw new FTPIllegalReplyException ( ) ; } else { try { return Long . parseLong ( messages [ 0 ] ) ; } catch ( Throwable t ) { throw new FTPIllegalReplyException ( ) ; } } } }
this method asks and returns a file size in bytes .
