Author: chatellier Date: 2011-06-15 09:12:26 +0000 (Wed, 15 Jun 2011) New Revision: 3397 Log: Fix stream closing Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ssh/SSHUtils.java Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ssh/SSHUtils.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ssh/SSHUtils.java 2011-06-15 09:08:57 UTC (rev 3396) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ssh/SSHUtils.java 2011-06-15 09:12:26 UTC (rev 3397) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2008 - 2010 Ifremer, Code Lutin, Chatellier Eric + * Copyright (C) 2008 - 2011 Ifremer, Code Lutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -394,11 +394,12 @@ } // read a content of lfile - FileOutputStream fos = new FileOutputStream(localFile); + FileOutputStream fos = null; int length; - long totalLength = 0; + //long totalLength = 0; try { + fos = new FileOutputStream(localFile); while (true) { length = in.read(buf, 0, (BUFFER_SIZE < filesize) ? BUFFER_SIZE : (int) filesize); @@ -407,7 +408,7 @@ } fos.write(buf, 0, length); filesize -= length; - totalLength += length; + //totalLength += length; if (filesize == 0) { break; } @@ -465,18 +466,19 @@ waitForAck(in); // send a content of lfile - FileInputStream fis = new FileInputStream(localFile); + FileInputStream fis = null; byte[] buf = new byte[BUFFER_SIZE]; - long totalLength = 0; + //long totalLength = 0; try { + fis = new FileInputStream(localFile); while (true) { int len = fis.read(buf, 0, buf.length); if (len <= 0) { break; } out.write(buf, 0, len); - totalLength += len; + //totalLength += len; } out.flush(); sendAck(out);