Mercurial > 510Connectbot
comparison app/src/main/java/ch/ethz/ssh2/SCPOutputStream.java @ 438:d29cce60f393
migrate from Eclipse to Android Studio
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 03 Dec 2015 11:23:55 -0800 |
parents | src/ch/ethz/ssh2/SCPOutputStream.java@071eccdff8ea |
children |
comparison
equal
deleted
inserted
replaced
437:208b31032318 | 438:d29cce60f393 |
---|---|
1 /* | |
2 * Copyright (c) 2011 David Kocher. All rights reserved. | |
3 * Please refer to the LICENSE.txt for licensing details. | |
4 */ | |
5 package ch.ethz.ssh2; | |
6 | |
7 import java.io.BufferedInputStream; | |
8 import java.io.BufferedOutputStream; | |
9 import java.io.IOException; | |
10 import java.io.InputStream; | |
11 | |
12 import ch.ethz.ssh2.util.StringEncoder; | |
13 | |
14 /** | |
15 * @version $Id: SCPOutputStream.java 151 2014-04-28 10:03:39Z dkocher@sudo.ch $ | |
16 */ | |
17 public class SCPOutputStream extends BufferedOutputStream { | |
18 | |
19 private Session session; | |
20 | |
21 private SCPClient scp; | |
22 | |
23 public SCPOutputStream(SCPClient client, Session session, final String remoteFile, long length, String mode) throws IOException { | |
24 super(session.getStdin(), 40000); | |
25 this.session = session; | |
26 this.scp = client; | |
27 InputStream is = new BufferedInputStream(session.getStdout(), 512); | |
28 scp.readResponse(is); | |
29 String cline = "C" + mode + " " + length + " " + remoteFile + "\n"; | |
30 super.write(StringEncoder.GetBytes(cline)); | |
31 this.flush(); | |
32 scp.readResponse(is); | |
33 } | |
34 | |
35 @Override | |
36 public void close() throws IOException { | |
37 try { | |
38 this.write(0); | |
39 this.flush(); | |
40 scp.readResponse(session.getStdout()); | |
41 this.write(StringEncoder.GetBytes("E\n")); | |
42 this.flush(); | |
43 } | |
44 finally { | |
45 if (session != null) | |
46 session.close(); | |
47 } | |
48 } | |
49 } |