コード例 #1
0
  @Override
  public void process(AssetEncounter encounter) throws IOException {
    Resource in = encounter.getResource();
    int length = in.getContentLength();
    if (length < 0) {
      length = 0;
      InputStream stream = in.openStream();
      while (stream.read() != -1) length++;
      stream.close();
    }

    byte[] data = String.valueOf(length).getBytes();
    encounter.replaceWith(new MemoryResource(null, null, data));
  }