Exemplo n.º 1
0
 /**
  * Returns an array of strings naming the files and directories in the directory denoted by this
  * abstract pathname.
  *
  * <p>There is no guarantee that the name strings in the resulting array will appear in any
  * specific order; they are not, in particular, guaranteed to appear in alphabetical order.
  *
  * <p>If this GeneralFile object denotes a file, the results are unspecified.
  *
  * @return An array of strings naming the files and directories in the directory denoted by this
  *     abstract pathname.
  */
 public String[] list() {
   try {
     // TODO which list?
     Vector list = ftpClient.list(getPath());
     Object[] listO = list.toArray();
     String[] listS = new String[listO.length];
     for (int i = 0; i < listO.length; i++) {
       listS[i] = listO[i].toString();
     }
     return listS;
   } catch (IOException e) {
     return null;
   } catch (FTPException e) {
     return null;
   }
 }
Exemplo n.º 2
0
  /**
   * Equivalent to ls command in the current directory
   *
   * @throws IOException
   * @throws FileResourceException
   */
  public Collection<GridFile> list() throws FileResourceException {
    List<GridFile> gridFileList = new ArrayList<GridFile>();
    try {
      ftpClient.setPassive();
      ftpClient.setLocalActive();
      ftpClient.setType(Session.TYPE_ASCII);

      Enumeration<?> list = ftpClient.list().elements();
      ftpClient.setType(Session.TYPE_IMAGE);

      while (list.hasMoreElements()) {
        gridFileList.add(createGridFile(list.nextElement()));
      }
      return gridFileList;
    } catch (Exception e) {
      throw translateException("Cannot list the elements of the current directory", e);
    }
  }