comparison src/ch/ethz/ssh2/SCPOutputStream.java @ 307:071eccdff8ea ganymed

fix java formatting
author Carl Byington <carl@five-ten-sg.com>
date Wed, 30 Jul 2014 14:16:58 -0700
parents 91a31873c42a
children
comparison
equal deleted inserted replaced
305:d2b303406d63 307:071eccdff8ea
12 import ch.ethz.ssh2.util.StringEncoder; 12 import ch.ethz.ssh2.util.StringEncoder;
13 13
14 /** 14 /**
15 * @version $Id: SCPOutputStream.java 151 2014-04-28 10:03:39Z dkocher@sudo.ch $ 15 * @version $Id: SCPOutputStream.java 151 2014-04-28 10:03:39Z dkocher@sudo.ch $
16 */ 16 */
17 public class SCPOutputStream extends BufferedOutputStream 17 public class SCPOutputStream extends BufferedOutputStream {
18 {
19 18
20 private Session session; 19 private Session session;
21 20
22 private SCPClient scp; 21 private SCPClient scp;
23 22
24 public SCPOutputStream(SCPClient client, Session session, final String remoteFile, long length, String mode) throws IOException 23 public SCPOutputStream(SCPClient client, Session session, final String remoteFile, long length, String mode) throws IOException {
25 { 24 super(session.getStdin(), 40000);
26 super(session.getStdin(), 40000); 25 this.session = session;
27 this.session = session; 26 this.scp = client;
28 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 }
29 34
30 InputStream is = new BufferedInputStream(session.getStdout(), 512); 35 @Override
31 36 public void close() throws IOException {
32 scp.readResponse(is); 37 try {
33 38 this.write(0);
34 String cline = "C" + mode + " " + length + " " + remoteFile + "\n"; 39 this.flush();
35 40 scp.readResponse(session.getStdout());
36 super.write(StringEncoder.GetBytes(cline)); 41 this.write(StringEncoder.GetBytes("E\n"));
37 this.flush(); 42 this.flush();
38 43 }
39 scp.readResponse(is); 44 finally {
40 } 45 if (session != null)
41 46 session.close();
42 @Override 47 }
43 public void close() throws IOException 48 }
44 {
45 try
46 {
47 this.write(0);
48 this.flush();
49
50 scp.readResponse(session.getStdout());
51
52 this.write(StringEncoder.GetBytes("E\n"));
53 this.flush();
54 }
55 finally
56 {
57 if (session != null)
58 session.close();
59 }
60 }
61 } 49 }