Exemplo n.º 1
0
 @Override
 public void writeInto(OutputStream responseBody) throws IOException {
   try {
     CountingOutputStream c = new CountingOutputStream(responseBody);
     IOUtils.copy(entity, c);
     this.length = c.getCount();
   } finally {
     IOUtils.closeQuietly(entity);
   }
 }
Exemplo n.º 2
0
 @Override
 public long getContentLength() {
   if (this.length == Long.MIN_VALUE) {
     if (ByteArrayInputStream.class.isInstance(entity)
         || FileInputStream.class.isInstance(entity)) {
       length = IOUtils.avairable(entity);
     } else {
       length = -1;
     }
   }
   return length;
 }