Package net.schmizz.sshj.common

Examples of net.schmizz.sshj.common.StreamCopier


        scp.getOutputStream().flush();
    }

    long transferToRemote(StreamCopier.Listener listener, InputStream src, long length)
            throws IOException {
        return new StreamCopier(src, scp.getOutputStream())
                .bufSize(scp.getRemoteMaxPacketSize()).length(length)
                .keepFlushing(false)
                .listener(listener)
                .copy();
    }
View Full Code Here


                .copy();
    }

    long transferFromRemote(StreamCopier.Listener listener, OutputStream dest, long length)
            throws IOException {
        return new StreamCopier(scp.getInputStream(), dest)
                .bufSize(scp.getLocalMaxPacketSize()).length(length)
                .keepFlushing(false)
                .listener(listener)
                .copy();
    }
View Full Code Here

                session.allocateDefaultPTY();

                final Shell shell = session.startShell();

                new StreamCopier(shell.getInputStream(), System.out)
                        .bufSize(shell.getLocalMaxPacketSize())
                        .spawn("stdout");

                new StreamCopier(shell.getErrorStream(), System.err)
                        .bufSize(shell.getLocalMaxPacketSize())
                        .spawn("stderr");

                // Now make System.in act as stdin. To exit, hit Ctrl+D (since that results in an EOF on System.in)
                // This is kinda messy because java only allows console input after you hit return
                // But this is just an example... a GUI app could implement a proper PTY
                new StreamCopier(System.in, shell.getOutputStream())
                        .bufSize(shell.getRemoteMaxPacketSize())
                        .copy();

            } finally {
                session.close();
View Full Code Here

        sock.connect(addr);

        // ok so far -- could connect, let's confirm the channel
        chan.confirm();

        final Event<IOException> soc2chan = new StreamCopier(sock.getInputStream(), chan.getOutputStream())
                .bufSize(chan.getRemoteMaxPacketSize())
                .spawnDaemon("soc2chan");

        final Event<IOException> chan2soc = new StreamCopier(chan.getInputStream(), sock.getOutputStream())
                .bufSize(chan.getLocalMaxPacketSize())
                .spawnDaemon("chan2soc");

        SocketStreamCopyMonitor.monitor(5, TimeUnit.SECONDS, chan2soc, soc2chan, chan, sock);
    }
View Full Code Here

            final RemoteFile rf = engine.open(remote.getPath());
            try {
                final RemoteFile.RemoteFileInputStream rfis = rf.new RemoteFileInputStream();
                final OutputStream os = adjusted.getOutputStream();
                try {
                    new StreamCopier(rfis, os)
                            .bufSize(engine.getSubsystem().getLocalMaxPacketSize())
                            .keepFlushing(false)
                            .listener(listener)
                            .copy();
                } finally {
View Full Code Here

                                                                   OpenMode.TRUNC));
            try {
                final InputStream fis = local.getInputStream();
                final RemoteFile.RemoteFileOutputStream rfos = rf.new RemoteFileOutputStream(0, 16);
                try {
                    new StreamCopier(fis, rfos)
                            .bufSize(engine.getSubsystem().getRemoteMaxPacketSize() - rf.getOutgoingPacketOverhead())
                            .keepFlushing(false)
                            .listener(listener)
                            .copy();
                } finally {
View Full Code Here

TOP

Related Classes of net.schmizz.sshj.common.StreamCopier

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.