File tree Expand file tree Collapse file tree 1 file changed +23
-24
lines changed
android/src/main/java/com/rnziparchive Expand file tree Collapse file tree 1 file changed +23
-24
lines changed Original file line number Diff line number Diff line change 77import static com .facebook .common .internal .Preconditions .checkNotNull ;
88
99public class StreamUtil {
10- private static final int BUF_SIZE = 0x1000 ; // 4K
10+ private static final int BUF_SIZE = 0x1000 ; // 4K
1111
12- public interface ProgressCallback {
13- // not the total - the actual number read since last time
14- void onCopyProgress (long bytesRead );
15- }
12+ public interface ProgressCallback {
13+ // not the total - the actual number read since last time
14+ void onCopyProgress (long bytesRead );
15+ }
1616
17- // https://stackoverflow.com/questions/4919690/how-to-read-one-stream-into-another
18- public static long copy (InputStream from , OutputStream to , ProgressCallback callback )
19- throws IOException {
20- checkNotNull (from );
21- checkNotNull (to );
22- byte [] buf = new byte [BUF_SIZE ];
23- long total = 0 ;
24- while (true ) {
25- int r = from .read (buf );
26- if (r == -1 ) {
27- break ;
28- }
29- to .write (buf , 0 , r );
30- total += r ;
17+ // https://stackoverflow.com/questions/4919690/how-to-read-one-stream-into-another
18+ public static long copy (InputStream from , OutputStream to , ProgressCallback callback ) throws IOException {
19+ checkNotNull (from );
20+ checkNotNull (to );
21+ byte [] buf = new byte [BUF_SIZE ];
22+ long total = 0 ;
23+ while (true ) {
24+ int r = from .read (buf );
25+ if (r == -1 ) {
26+ break ;
27+ }
28+ to .write (buf , 0 , r );
29+ total += r ;
3130
32- if (callback != null ) {
33- callback .onCopyProgress (r );
34- }
35- }
36- return total ;
31+ if (callback != null ) {
32+ callback .onCopyProgress (r );
33+ }
3734 }
35+ return total ;
36+ }
3837}
You can’t perform that action at this time.
0 commit comments