Mercurial > jhg
diff src/org/tmatesoft/hg/internal/FileUtils.java @ 697:24f4efedc9d5
Respect the fact ssh and http protocols use different compression approach to sent changegroup data
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 06 Aug 2013 13:34:34 +0200 |
parents | 12a4f60ea972 |
children | b4242b7e7dfe |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/FileUtils.java Mon Aug 05 19:03:22 2013 +0200 +++ b/src/org/tmatesoft/hg/internal/FileUtils.java Tue Aug 06 13:34:34 2013 +0200 @@ -23,6 +23,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.nio.channels.FileChannel; import org.tmatesoft.hg.core.HgIOException; @@ -93,6 +94,17 @@ * Windows uncached run: 1.6 seconds */ } + + public void write(InputStream is, File file) throws IOException { + FileOutputStream fos = new FileOutputStream(file); + int r; + byte[] buf = new byte[8*1024]; + while ((r = is.read(buf)) != -1) { + fos.write(buf, 0, r); + } + fos.flush(); + fos.close(); + } public void closeQuietly(Closeable stream) { closeQuietly(stream, null);