Esempio n. 1
0
 public static void copyStreams(
     InputStream in,
     OutputStream out,
     boolean doCloseInput,
     boolean doCloseOutput,
     final ProgressUpdateListener progress)
     throws IOException {
   byte[] buffer = new byte[2048];
   int count = 0;
   int total = 0;
   while ((count = in.read(buffer)) != -1) {
     if (progress.isCancelled()) break;
     out.write(buffer, 0, count);
     total += count;
     if (progress != null) {
       final int t = total;
       OpenExplorer.getHandler()
           .post(
               new Runnable() {
                 public void run() {
                   progress.onProgressUpdate(t);
                 }
               });
     }
   }
   if (doCloseInput)
     try {
       if (in != null) in.close();
     } catch (Exception e) {
     }
   if (doCloseOutput)
     try {
       if (out != null) out.close();
     } catch (Exception e) {
     }
 }
Esempio n. 2
0
 public static void post(Runnable r) {
   OpenExplorer.post(r);
 }