Package com.jcraft.jsch

Examples of com.jcraft.jsch.ChannelSftp.connect()


        boolean bDownloaded = true;
        try
        {
            ChannelSftp channel = (ChannelSftp) session.openChannel( SFTP_CHANNEL );

            channel.connect();

            SftpATTRS attrs = changeToRepositoryDirectory( channel, dir, filename );

            if ( timestamp <= 0 || attrs.getMTime() * MILLIS_PER_SEC > timestamp )
            {
View Full Code Here


                    });

                    session.connect();

                    channel = (ChannelSftp) session.openChannel("sftp");
                    channel.connect();

                    String charset = uri.getOption("charset");

                    if (charset != null) {
                        channel.setFilenameEncoding(charset);
View Full Code Here

    final Session session = newSession();

    final ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");

    channel.connect();

    //

    final SftpProgressMonitor monitor = new SftpProgressMonitor() {
View Full Code Here

        File target = new File(unixPath);
        root.mkdirs();
        assertTrue(root.exists());

        ChannelSftp c = (ChannelSftp) session.openChannel("sftp");
        c.connect();
        c.put(new ByteArrayInputStream("0123456789".getBytes()), unixPath);

        assertTrue(target.exists());
        assertEquals("0123456789", readFile(unixPath));
View Full Code Here

    }

    @Test
    public void testReadDir() throws Exception {
        ChannelSftp c = (ChannelSftp) session.openChannel("sftp");
        c.connect();
        Vector res = c.ls("target/classes/org/apache/sshd/");
        for (Object f : res) {
            System.out.println(f.toString());
        }
    }
View Full Code Here

        assertEquals(length, file.length());
    }

    protected String readFile(String path) throws Exception {
        ChannelSftp c = (ChannelSftp) session.openChannel("sftp");
        c.connect();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        InputStream is = c.get(path);
        try {
            byte[] buffer = new byte[256];
            int count;
View Full Code Here

        return new String(bos.toByteArray());
    }

    protected void sendFile(String path, String data) throws Exception {
        ChannelSftp c = (ChannelSftp) session.openChannel("sftp");
        c.connect();
        c.put(new ByteArrayInputStream(data.getBytes()), path);
        c.disconnect();
    }

    public static void main(String[] args) throws Exception {
View Full Code Here

        Utils.deleteRecursive(root);
        root.mkdirs();
        assertTrue(root.exists());

        ChannelSftp c = (ChannelSftp) session.openChannel("sftp");
        c.connect();
        c.put(new ByteArrayInputStream("0123456789".getBytes()), unixPath);

        assertTrue(target.exists());
        assertEquals("0123456789", readFile(unixPath));
View Full Code Here

    }

    @Test
    public void testReadDir() throws Exception {
        ChannelSftp c = (ChannelSftp) session.openChannel("sftp");
        c.connect();
        Vector res = c.ls("target/classes/org/apache/sshd/");
        for (Object f : res) {
            System.out.println(f.toString());
        }
    }
View Full Code Here

        assertEquals(length, file.length());
    }

    protected String readFile(String path) throws Exception {
        ChannelSftp c = (ChannelSftp) session.openChannel("sftp");
        c.connect();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        InputStream is = c.get(path);
        try {
            byte[] buffer = new byte[256];
            int count;
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.