Changeset 5699


Ignore:
Timestamp:
11/17/09 13:24:13 (10 years ago)
Author:
curtis
Message:

Better feedback when caching data with "-preload" flag.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/tools/ImageInfo.java

    r5611 r5699  
    275275    else if (preload) { 
    276276      RandomAccessInputStream f = new RandomAccessInputStream(id); 
    277       byte[] b = new byte[(int) f.length()]; 
    278       f.read(b); 
     277      int len = (int) f.length(); 
     278      LogTools.println("Caching " + len + " bytes:"); 
     279      byte[] b = new byte[len]; 
     280      int blockSize = 8 * 1024 * 1024; // 8 MB 
     281      int read = 0, left = len; 
     282      while (left > 0) { 
     283        int r = f.read(b, read, blockSize < left ? blockSize : left); 
     284        read += r; 
     285        left -= r; 
     286        float ratio = (float) read / len; 
     287        int p = (int) (100 * ratio); 
     288        LogTools.println("\tRead " + read + " bytes (" + p + "% complete)"); 
     289      } 
    279290      f.close(); 
    280291      ByteArrayHandle file = new ByteArrayHandle(b); 
Note: See TracChangeset for help on using the changeset viewer.