Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void copyStreams(InputStream is, OutputStream os, long totalBytes,
- FileSenderInterface fileSenderI)
- {
- if (is != null && os != null)
- {
- byte[] mybytearray = new byte[4096];
- try
- {
- while (is.read(mybytearray) != -1)
- {
- int length = mybytearray.length;
- os.write(mybytearray, 0, length);
- if (fileSenderI != null)
- {
- int progress = (int) (length / totalBytes * 100);
- fileSenderI.onWrite(progress);
- }
- }
- os.flush();
- }
- catch (IOException e)
- {
- logError(e);
- }
- finally
- {
- try
- {
- os.close();
- }
- catch (IOException e)
- {
- logError(e);
- }
- }
- }
- }
- public interface FileSenderInterface
- {
- void onWrite(int progress);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement