Examples of FtpClient


Examples of org.apache.commons.net.ftp.FTPClient

    private AbstractDownload download;
    private boolean restart;

    FtpClient(DownloadSettings settings) {
        this.settings = settings;
        client = new FTPClient();
    }
View Full Code Here

Examples of org.apache.commons.net.ftp.FTPClient

  private Properties      properties  = new Properties();

  private boolean initConnection() {
    try {
      if (ftp == null) {
        ftp = new FTPClient();
        serverIP = getServer();
        userName = getUserName();
        password = getPassword();
      }
      ftp.connect(serverIP);
View Full Code Here

Examples of org.globus.ftp.FTPClient

  }

  public void connect(String host, String username, String password)
          throws ProtocolException {
      try {
          ftp = new FTPClient(host, 21);
      } catch (Exception e) {
          throw new ProtocolException("Failed to connect to: " + host + " : "
                  + e.getMessage());
      }
      isConnected = true;
View Full Code Here

Examples of org.h2.dev.ftp.FtpClient

    private void test(String dir) throws Exception {
        Server server = FtpServer.createFtpServer("-ftpDir", dir, "-ftpPort", "8121").start();
        FtpServer ftp = (FtpServer) server.getService();
        ftp.setEventListener(this);
        FtpClient client = FtpClient.open("localhost:8121");
        client.login("sa", "sa");
        client.makeDirectory("test");
        client.changeWorkingDirectory("test");
        assertEquals("CWD", lastEvent.getCommand());
        client.makeDirectory("hello");
        client.changeWorkingDirectory("hello");
        client.changeDirectoryUp();
        assertEquals("CDUP", lastEvent.getCommand());
        client.nameList("hello");
        client.removeDirectory("hello");
        client.close();
        server.stop();
    }
View Full Code Here

Examples of sun.net.ftp.FtpClient

   */
  public static final Any ftpPut(String urlString, Any anyData, int type)
      throws IOException, UnserializationException
  {
    FtpURL  ftpURL = new FtpURL(urlString);
    FtpClient ftpClient = new FtpClient(ftpURL.host);
    ftpClient.login(ftpURL.user,ftpURL.pass);
    ftpClient.binary();
    ftpClient.cd(ftpURL.dir);

    BufferedWriter writer;
    Any result;

    switch (type) {

    case StreamUtils.TYPE_STRING:
      writer = new BufferedWriter(new OutputStreamWriter(ftpClient.put(ftpURL.file)));
      writer.write(anyData.toString());
      writer.close();
      result = Any.TRUE;
      break;

    case StreamUtils.TYPE_LINES:
      writer = new BufferedWriter(new OutputStreamWriter(ftpClient.put(ftpURL.file)));
      result = StreamUtils.linesToWriter(anyData,writer);
      break;

    case StreamUtils.TYPE_BINARY:
      OutputStream out = ftpClient.put(ftpURL.file);
      byte[] byteArray = (byte[])(anyData.toObject());
      out.write(byteArray);
      out.close();
      result = Any.TRUE;
      break;

    case StreamUtils.TYPE_DATA:
      OutputStream outs = ftpClient.put(ftpURL.file);
      Serialization.serialize(null, anyData, outs);
      outs.close();
      result = Any.TRUE;
      break;

    default:
      result = Any.FALSE;
      break;
    }
    try {
      ftpClient.closeServer();
    } catch (Exception e) {
      //anvil.Log.log().error("Can not close ftp connection");
    }
    return result;
  }
View Full Code Here

Examples of sun.net.ftp.FtpClient

   */
  public static final Any ftpPutString(String urlString, String string)
      throws IOException, UnserializationException
  {
    FtpURL  ftpURL  = new FtpURL(urlString);
    FtpClient ftpClient = new FtpClient(ftpURL.host);
    ftpClient.login(ftpURL.user,ftpURL.pass);
    ftpClient.binary();
    ftpClient.cd(ftpURL.dir);

    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(ftpClient.put(ftpURL.file)));
    writer.write(string);
    writer.close();
    Any result = Any.TRUE;
    try {
      ftpClient.closeServer();
    } catch (Exception e) {
      //anvil.Log.log().error("Can not close ftp connection");
    }
    return result;
  }
View Full Code Here

Examples of sun.net.ftp.FtpClient

  /// @throws IOError if an IO error occured
  public static final Object[] newInstance = { null, "*address", null, "*port", new Integer(0) };
  public static final Any newInstance(Context context, Any host, int port)
  {
    try {
      FtpClient client;
      if (host != null) {
        String hostname;
        if (host instanceof AnyInetAddress) {
          hostname = ((InetAddress)host.toObject()).getHostName();
        } else {
          hostname = host.toString();
        }
        if (port == 0) {
          port = FtpClient.FTP_PORT;
        }
        context.checkConnect(hostname, port);
        client = new FtpClient(hostname, port);
      } else {
        client = new FtpClient();
      }
      return new AnyFtpClient(client);
    } catch (IOException e) {
      throw context.exception(e);
    }
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.