コード例 #1
0
 @Override
 public void run() {
   try {
     if (channel == null) channel = new FileInputStream(file).getChannel();
     if (!pending.isEmpty()) {
       Util.emitAllData(FileDataEmitter.this, pending);
       if (!pending.isEmpty()) return;
     }
     ByteBuffer b;
     do {
       b = ByteBufferList.obtain(8192);
       if (-1 == channel.read(b)) {
         report(null);
         return;
       }
       b.flip();
       pending.add(b);
       Util.emitAllData(FileDataEmitter.this, pending);
     } while (pending.remaining() == 0 && !isPaused());
   } catch (Exception e) {
     report(e);
   }
 }