Package com.enterprisedt.net.ftp

Examples of com.enterprisedt.net.ftp.FileTransferClient


        // set up logger so that we get some output
        Logger log = Logger.getLogger(TransferUsingStreams.class);
        Logger.setLevel(Level.INFO);

        FileTransferClient ftp = null;

        try {
            // create client
            log.info("Creating FTP client");
            ftp = new FileTransferClient();

            // set remote host
            ftp.setRemoteHost(host);
            ftp.setUserName(username);
            ftp.setPassword(password);

            // connect to the server
            log.info("Connecting to server " + host);
            ftp.connect();
            log.info("Connected and logged in to server " + host);

            // byte array transfers
            String s1 = "Hello world";

            log.info("Putting s1");
            OutputStream out = ftp.uploadStream("Hello.txt");
            try {
                out.write(s1.getBytes());
            }
            finally {
                out.close(); // MUST be closed to complete the transfer
            }

            log.info("Retrieving as s2");
            StringBuffer s2 = new StringBuffer();
            InputStream in = ftp.downloadStream("Hello.txt");
            try {
                int ch = 0;
                while ((ch = in.read()) >= 0) {
                    s2.append((char)ch);
                }
            }
            finally {
                in.close(); // MUST be closed to complete the transfer
            }
               
            log.info("s1 == s2: " + s1.equals(s2.toString()));
           
            ftp.deleteFile("Hello.txt");

            // Shut down client
            log.info("Quitting client");
            ftp.disconnect();

            log.info("Example complete");

        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here


        // set up logger so that we get some output
        Logger log = Logger.getLogger(MonitorTransfersCommands.class);
        Logger.setLevel(Level.INFO);

        FileTransferClient ftp = null;

        try {
            // create client
            log.info("Creating FTP client");
            ftp = new FileTransferClient();

            // set remote host
            ftp.setRemoteHost(host);
            ftp.setUserName(username);
            ftp.setPassword(password);
           
            // set up listener
            ftp.setEventListener(new EventListenerImpl());
           
            // the transfer notify interval must be greater than buffer size
            ftp.getAdvancedSettings().setTransferBufferSize(500);
            ftp.getAdvancedSettings().setTransferNotifyInterval(1000);

            // connect to the server
            log.info("Connecting to server " + host);
            ftp.connect();
            log.info("Connected and logged in to server " + host);

            log.info("Uploading file");
            String name = "MonitorTransfersCommands.java";

            // put the file
            ftp.uploadFile(name, name);
            log.info("File uploaded");

            // now delete remote file
            ftp.deleteFile(name);

            // Shut down client
            log.info("Quitting client");
            ftp.disconnect();

            log.info("Example complete");

        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

public class Uploader
{
  public static void Upload(String src, int team) throws FTPException, IOException
  {
    FileTransferClient ftp = new FileTransferClient();
    ftp.setRemoteHost("10." + (team / 100) + "." + (team % 100) + ".2");
    ftp.connect();
    // (project)/PPC603gnu/projectname/Debug/projectname.out
    ftp.uploadFile(src, "/ni-rt/system/FRC_UserProgram.out");
    ftp.disconnect();
  }
View Full Code Here

    ftp.uploadFile(src, "/ni-rt/system/FRC_UserProgram.out");
    ftp.disconnect();
  }
  public static void Delete(int team) throws FTPException, IOException
  {
    FileTransferClient ftp = new FileTransferClient();
    ftp.setRemoteHost("10." + (team / 100) + "." + (team % 100) + ".2");
    ftp.connect();
    // (project)/PPC603gnu/projectname/Debug/projectname.out
    ftp.deleteFile("/ni-rt/system/FRC_UserProgram.out");
    ftp.disconnect();
  }
View Full Code Here

TOP

Related Classes of com.enterprisedt.net.ftp.FileTransferClient

Copyright © 2018 www.massapicom. 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.