Java Code Examples for org.apache.commons.net.ftp.FTPFile#getType()

The following examples show how to use org.apache.commons.net.ftp.FTPFile#getType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainframeFTPClientUtils.java    From aliyun-maxcompute-data-collectors with Apache License 2.0 6 votes vote down vote up
public static List<String> listSequentialDatasets(
    String pdsName, Configuration conf) throws IOException {
  List<String> datasets = new ArrayList<String>();
  FTPClient ftp = null;
  try {
    ftp = getFTPConnection(conf);
    if (ftp != null) {
      ftp.changeWorkingDirectory("'" + pdsName + "'");
      FTPFile[] ftpFiles = ftp.listFiles();
      for (FTPFile f : ftpFiles) {
        if (f.getType() == FTPFile.FILE_TYPE) {
          datasets.add(f.getName());
        }
      }
    }
  } catch(IOException ioe) {
    throw new IOException ("Could not list datasets from " + pdsName + ":"
        + ioe.toString());
  } finally {
    if (ftp != null) {
      closeFTPConnection(ftp);
    }
  }
  return datasets;
}
 
Example 2
Source File: MainframeFTPClientUtils.java    From spark-mainframe-connector with Apache License 2.0 6 votes vote down vote up
public static List<String> listSequentialDatasets(
    String pdsName, TransferableContext context, LinkConfiguration linkConfiguration) throws IOException {
  List<String> datasets = new ArrayList<String>();
  FTPClient ftp = null;
  try {
    ftp = getFTPConnection(context, linkConfiguration);
    if (ftp != null) {
      setWorkingDirectory(context, ftp, pdsName);
      FTPFile[] ftpFiles = ftp.listFiles();
      for (FTPFile f : ftpFiles) {
        if (f.getType() == FTPFile.FILE_TYPE) {
          datasets.add(f.getName());
        }
      }
    }
  } catch(IOException ioe) {
    throw new IOException ("Could not list datasets from " + pdsName + ":"
        + ioe.toString());
  } finally {
    if (ftp != null) {
      closeFTPConnection(ftp);
    }
  }
  return datasets;
}
 
Example 3
Source File: FtpFileSystem.java    From xenon with Apache License 2.0 3 votes vote down vote up
@Override
public Path readSymbolicLink(Path path) throws XenonException {

    Path absPath = toAbsolutePath(path);

    FTPFile file = getFTPFileInfo(absPath);

    if (file.getType() != FTPFile.SYMBOLIC_LINK_TYPE) {
        throw new InvalidPathException(ADAPTOR_NAME, "Path is not a symbolic link: " + absPath);
    }

    return new Path(file.getLink());
}