Package com.enterprisedt.util.debug

Examples of com.enterprisedt.util.debug.Logger


    public static void main(String[] args) {
        if (args.length < 2) {
            usage();
        }
       
        Logger log = Logger.getLogger(FileParserTest.class);
        Logger.setLevel(Level.ALL);
       
        String type = args[0];
        String filename = args[1];
        String locale = null;
        if (args.length ==3)
            locale = args[2];
        FTPFileParser parser = null;
        try {
            Class clazz = Class.forName(type);
            parser = (FTPFileParser)clazz.newInstance();
        }
        catch (Throwable t) {
            usage();
        }
        log.debug("Type=" + type);
       
        Vector lines = new Vector();
        BufferedReader reader = null;
        String line = null;
        try {
View Full Code Here


        String host = args[0];
        String username = args[1];
        String password = args[2];

        // set up logger so that we get some output
        Logger log = Logger.getLogger(PauseResumeTransfers.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
            CancelListener cl = new CancelListener(ftp);
            ftp.setEventListener(cl);
           
            // 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 = "PauseResumeTransfers.java";

            // the upload will be interrupted by the listener - it will call
            // cancelAllTransfers(). We catch the expected exception.
            try {
                ftp.uploadFile(name, name);
            }
            catch (FTPTransferCancelledException ex) {
                log.debug("Transfer cancelled");
            }
            int len = (int) ftp.getSize(name);
            File file = new File(name);
            log.info("Bytes transferred=" + cl.getBytesTransferred());
            log.info("File partially uploaded (localsize=" + file.length()
                    + " remotesize=" + len);

            log.info("Completing upload by resuming");
            ftp.uploadFile(name, name, WriteMode.RESUME);
            len = (int) ftp.getSize(name);

            // only the remaining bytes are transferred as can be seen
            log.info("Bytes transferred=" + cl.getBytesTransferred());
            log.info("File uploaded (localsize=" + file.length()
                    + " remotesize=" + len);

            // 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

        String host = args[0];
        String username = args[1];
        String password = args[2];

        // set up logger so that we get some output
        Logger log = Logger.getLogger(UseTransferModes.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);

            ftp.setContentType(FTPTransferType.BINARY);
            uploadDownloadDelete("UseTransferModes.java", ftp);
            log.info("Successfully transferred in binary mode");

            ftp.setContentType(FTPTransferType.ASCII);
            uploadDownloadDelete("UseTransferModes.java", ftp);
            log.info("Successfully transferred in ASCII mode");

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

            log.info("Example complete");

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

        String username = args[1];
        String password = args[2];
        String filename = "UploadDownloadFiles.java";

        // set up logger so that we get some output
        Logger log = Logger.getLogger(UploadDownloadFiles.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);

            log.info("Uploading file");
            ftp.uploadFile(filename, filename);
            log.info("File uploaded");

            log.info("Downloading file");
            ftp.downloadFile(filename + ".copy", filename);
            log.info("File downloaded");

            log.info("Deleting remote file");
            ftp.deleteFile(filename);
            log.info("Deleted remote file");

            File file = new File(filename + ".copy");
            file.delete();
            log.info("Deleted local file copy");

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

            log.info("Example complete");

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

    public static void main(String[] args) {

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

            // log to a file and also to standard output
            Logger.addAppender(new FileAppender("output.log"));
            Logger.addAppender(new StandardOutputAppender());

            // this will not appear unless the level is set to DEBUG
            log.debug("This is a debug message");

            // this will appear with the level set to INFO
            log.info("This is an info message");

            // this will appear with the level set to INFO
            log.error("This is an error message");

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

        String host = args[0];
        String username = args[1];
        String password = args[2];

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

        FileTransferClient ftp = null;

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

            // set remote host
            log.info("Setting 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);

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

            log.info("Example complete");

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

        String host = args[0];
        String username = args[1];
        String password = args[2];

        // set up logger so that we get some output
        Logger log = Logger.getLogger(UseConnectModes.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);

            ftp.getAdvancedFTPSettings().setConnectMode(FTPConnectMode.ACTIVE);
            uploadDownloadDelete("UseConnectModes.java", ftp);
            log.info("Successfully transferred in active mode");

            ftp.getAdvancedFTPSettings().setConnectMode(FTPConnectMode.PASV);
            uploadDownloadDelete("UseConnectModes.java", ftp);
            log.info("Successfully transferred in passive mode");

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

            log.info("Example complete");

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

        String host = args[0];
        String username = args[1];
        String password = args[2];

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

        FileTransferClient ftp = null;

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

            // set remote host
            log.info("Setting 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);

            log.info("Getting current directory listing");
            FTPFile[] files = ftp.directoryList(".");
            for (int i = 0; i < files.length; i++) {
                log.info(files[i].toString());
            }

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

            log.info("Example complete");

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

        String username = args[1];
        String password = args[2];
        String dir = args[3];

        // set up logger so that we get some output
        Logger log = Logger.getLogger(ChangeDirectory.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);

            log.info("Current dir: " + ftp.getRemoteDirectory());
            log.info("Changing directory");
            ftp.changeDirectory(dir);
            log.info("Current dir: " + ftp.getRemoteDirectory());

            log.info("Changing up");
            ftp.changeToParentDirectory();
            log.info("Current dir: " + ftp.getRemoteDirectory());

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

            log.info("Example complete");

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

        String host = args[0];
        String username = args[1];
        String password = args[2];

        // 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

TOP

Related Classes of com.enterprisedt.util.debug.Logger

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.