Package it.sauronsoftware.ftp4j

Examples of it.sauronsoftware.ftp4j.FTPClient


            __tempResource = null;
        }
    }

    public InputStream openInputStream() throws IOException {
        final FTPClient client = this.getClient();
        if (null != client
                && client.isConnected()) {
            return this.openInputStream(this.getTempFile());
        }
        return null;
    }
View Full Code Here


        }
        return null;
    }

    public OutputStream openOutputStream() throws IOException {
        final FTPClient client = this.getClient();
        if (null != client
                && client.isConnected()) {
            return this.openOutputStream(this.getTempFile());
        }
        return null;
    }
View Full Code Here

    public String[] getChildren() {
        return this.getChildren(0);
    }

    public String[] getChildren(int deepLevel) {
        final FTPClient client = this.getClient();
        if (null != client
                && client.isConnected()
                && StringUtils.hasText(_workingFolder)) {
            try {
                client.changeDirectory("/");
                final LinkedList<String> list = new LinkedList<String>();
                this.getChildren(client,
                        list, "",
                        0, deepLevel);
View Full Code Here

        }
        return new String[0];
    }

    public boolean mkdirs() {
        final FTPClient client = this.getClient();
        if (null != client
                && client.isConnected()
                && StringUtils.hasText(_workingFolder)) {
            try {
                client.changeDirectory("/");
                if (!_workingFolder.equalsIgnoreCase("/")) {
                    client.createDirectory(_workingFolder);
                }
                return true;
            } catch (FTPException ex) {
                if (ex.getCode() == 550) {
                    return true;
View Full Code Here

        }
        return false;
    }

    public void delete() {
        final FTPClient client = this.getClient();
        if (null != client
                && client.isConnected()) {
            try {
                if (StringUtils.hasText(_fileName)) {
                    client.deleteFile(_url);
                } else {
                    client.deleteDirectory(_url);
                }
            } catch (Throwable t) {
            }
        }
    }
View Full Code Here

        return LoggingUtils.getLogger(this);
    }

    private FTPClient getClient() {
        if (null == __client) {
            __client = new FTPClient();
        }
        // connection
        if (!__client.isConnected()) {
            try {
                __client.connect(_host, _port);
View Full Code Here

        }
        return null;
    }

    private void download(final File temp) throws Exception {
        final FTPClient client = this.getClient();
        if (null != client
                && client.isConnected()
                && StringUtils.hasText(_fileName)) {
            try {
                client.changeDirectory("/");
                if (StringUtils.hasText(_workingFolder)) {
                    client.changeDirectory(_workingFolder);
                }
                client.download(_fileName, temp);
            } catch (FTPException ex) {
                // file doe not exists, file not found
                if (ex.getCode() != 450
                        && ex.getCode() != 550) {
                    throw ex;
View Full Code Here

            }
        }
    }

    private void upload(final File file) throws Exception {
        final FTPClient client = this.getClient();
        if (null != client
                && client.isConnected()
                && StringUtils.hasText(_fileName)) {
            if (file.exists()) {
                final FileInputStream is = new FileInputStream(file);
                try {
                    client.changeDirectory("/");
                    if (StringUtils.hasText(_workingFolder)) {
                        client.changeDirectory(_workingFolder);
                    }
                    client.upload(_fileName, is, 0, 0, null);
                } finally {
                    is.close();
                }
            }
        }
View Full Code Here

        while ( br.readLine() != null) {
            ;
        }

        FTPClient client = new FTPClient();
        client.connect(Shared.getConfig("ftpBackupAddr"), Integer.parseInt(Shared.getConfig("ftpPort")));
        client.login(Shared.getConfig("ftpBackupUser"), Shared.getConfig("ftpBackupPassword"));
        client.changeDirectory("/" + Shared.getConfig("storeName"));
        File f = new File(Constants.tmpDir + fileName);
        client.upload(f);
        client.disconnect(false);

    }
View Full Code Here

    public void doIt() {
        try {
            Shared.createBackup("articulo precio codigo_de_barras costo movimiento_inventario detalles_movimientos");

            if ( mode.equals("FTP") ){
                FTPClient client = new FTPClient();
                client.connect(Shared.getConfig("ftpHost"));
                client.login(Shared.getConfig("ftpUser"), Shared.getConfig("ftpPass"));
                client.changeDirectory(Shared.getConfig("ftpDir"));
                File ff = new File(Constants.tmpDir + Shared.getConfig("tmpFtpFileName"));
                client.download("GT99_A09.rar", ff );
                client.disconnect(false);
                Shared.prepareMovements( ff );
            }else if ( mode.equals("File") ) {
                JFileChooser jfc = new JFileChooser();
                FileFilter f = new ExtensionFileFilter("Traslados de Total Pos","rar");
                jfc.setFileFilter(f);
View Full Code Here

TOP

Related Classes of it.sauronsoftware.ftp4j.FTPClient

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.