Package org.apache.commons.net.ftp

Examples of org.apache.commons.net.ftp.FTPClient.changeWorkingDirectory()


                else {
                    ftpClient.login("anonymous", "");
                }
                // cd to directory
                if(StringUtils.isNotEmpty(path)) {
                    ftpClient.changeWorkingDirectory(path);
                }

                //
                // transfer file
                //
View Full Code Here


    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());
          }
View Full Code Here

  public void transport(File file) throws TransportException {
    FTPClient client = new FTPClient();
    try {
      client.connect(getOption("host"));
      client.login(getOption("username"), getOption("password"));
      client.changeWorkingDirectory(getOption("remotePath"));
      transportRecursive(client, file);
      client.disconnect();
    } catch (Exception e) {
      throw new TransportException(e);
    }
View Full Code Here

        }
        String path = url.getPath();
        String workingDir = path.substring(0, path.lastIndexOf("/"));
        String file = path.substring(path.lastIndexOf("/")+1);

        ftp.changeWorkingDirectory(workingDir);
        ftp.setFileType(FTPClient.BINARY_FILE_TYPE);

        InputStream input = new FilterInputStream(ftp.retrieveFileStream(file)) {

            public void close() throws IOException {
View Full Code Here

        String workingDir = path.substring(0, path.lastIndexOf("/"));
    String filename = message.getMessageId().toString().replaceAll(":", "_");
        ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
       
        String url;
        if(!ftp.changeWorkingDirectory(workingDir)) {
          url = this.url.toString().replaceFirst(this.url.getPath(), "")+"/";
        } else {
          url = this.url.toString();
        }
       
View Full Code Here

    if(!ftp.login("activemq", "activemq")) {
      ftp.quit();
      ftp.disconnect();
      throw new JMSException("Cant Authentificate to FTP-Server");
    }
    ftp.changeWorkingDirectory("ftptest");
    ftp.deleteFile("testmessage");
    ftp.quit();
    ftp.disconnect();
    }
 
View Full Code Here

    // file
    // on the server by opening up an InputStream. As a side effect the working
    // directory on the server is changed to the parent directory of the file.
    // The FTP client connection is closed when close() is called on the
    // FSDataInputStream.
    client.changeWorkingDirectory(parent.toUri().getPath());
    InputStream is = client.retrieveFileStream(file.getName());
    FSDataInputStream fis = new FSDataInputStream(new FTPInputStream(is,
        client, statistics));
    if (!FTPReply.isPositivePreliminary(client.getReplyCode())) {
      // The ftpClient is an inconsistent state. Must close the stream
View Full Code Here

    // Change to parent directory on the server. Only then can we write to the
    // file on the server by opening up an OutputStream. As a side effect the
    // working directory on the server is changed to the parent directory of the
    // file. The FTP client connection is closed when close() is called on the
    // FSDataOutputStream.
    client.changeWorkingDirectory(parent.toUri().getPath());
    FSDataOutputStream fos = new FSDataOutputStream(client.storeFileStream(file
        .getName()), statistics) {
      @Override
      public void close() throws IOException {
        super.close();
View Full Code Here

      FTPClient ftp = getClient();
      if (ftp != null) {
        String filename = getPath() + remote;
        String name = FilenameUtils.getName(filename);
        String path = FilenameUtils.getFullPath(filename);
        if (!ftp.changeWorkingDirectory(path)) {
          String[] ps = StringUtils.split(path, '/');
          String p = "/";
          ftp.changeWorkingDirectory(p);
          for (String s : ps) {
            p += s + "/";
View Full Code Here

        String name = FilenameUtils.getName(filename);
        String path = FilenameUtils.getFullPath(filename);
        if (!ftp.changeWorkingDirectory(path)) {
          String[] ps = StringUtils.split(path, '/');
          String p = "/";
          ftp.changeWorkingDirectory(p);
          for (String s : ps) {
            p += s + "/";
            if (!ftp.changeWorkingDirectory(p)) {
              ftp.makeDirectory(s);
              ftp.changeWorkingDirectory(p);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.