Mercurial > hg4j
comparison 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 |
comparison
equal
deleted
inserted
replaced
696:5b5d199e2eb3 | 697:24f4efedc9d5 |
---|---|
21 import java.io.Closeable; | 21 import java.io.Closeable; |
22 import java.io.File; | 22 import java.io.File; |
23 import java.io.FileInputStream; | 23 import java.io.FileInputStream; |
24 import java.io.FileOutputStream; | 24 import java.io.FileOutputStream; |
25 import java.io.IOException; | 25 import java.io.IOException; |
26 import java.io.InputStream; | |
26 import java.nio.channels.FileChannel; | 27 import java.nio.channels.FileChannel; |
27 | 28 |
28 import org.tmatesoft.hg.core.HgIOException; | 29 import org.tmatesoft.hg.core.HgIOException; |
29 import org.tmatesoft.hg.util.LogFacility; | 30 import org.tmatesoft.hg.util.LogFacility; |
30 import org.tmatesoft.hg.util.LogFacility.Severity; | 31 import org.tmatesoft.hg.util.LogFacility.Severity; |
91 /* Copy of cpython's 00changelog.d, 20Mb+ | 92 /* Copy of cpython's 00changelog.d, 20Mb+ |
92 * Linux&Windows: 300-400 ms, | 93 * Linux&Windows: 300-400 ms, |
93 * Windows uncached run: 1.6 seconds | 94 * Windows uncached run: 1.6 seconds |
94 */ | 95 */ |
95 } | 96 } |
97 | |
98 public void write(InputStream is, File file) throws IOException { | |
99 FileOutputStream fos = new FileOutputStream(file); | |
100 int r; | |
101 byte[] buf = new byte[8*1024]; | |
102 while ((r = is.read(buf)) != -1) { | |
103 fos.write(buf, 0, r); | |
104 } | |
105 fos.flush(); | |
106 fos.close(); | |
107 } | |
96 | 108 |
97 public void closeQuietly(Closeable stream) { | 109 public void closeQuietly(Closeable stream) { |
98 closeQuietly(stream, null); | 110 closeQuietly(stream, null); |
99 } | 111 } |
100 | 112 |