code: private static int chunkSize(final InputStream stream)
          throws IOException {
          final ByteArrayOutputStream baos = ChunkedInputStream.sizeLine(stream);
          final int result;
          final String data = baos.toString(Charset.defaultCharset().name());
          final int separator = data.indexOf(';');
          try {
              // @checkstyle MagicNumberCheck (10 lines)
              if (separator > 0) {
                  result = Integer.parseInt(
                      data.substring(0, separator).trim(),
                      16
                  );
              } else {
                  result = Integer.parseInt(data.trim(), 16);
              }
              return result;
          } catch (final NumberFormatException ex) {
              throw new IOException(
                  String.format(
                      "Bad chunk size: %s",
                      baos.toString(Charset.defaultCharset().name())
                  ),
                  ex
              );
          }
      }
docs: Expects the stream to start with a chunksize in hex with optional
  comments after a semicolon. The line must end with a CRLF: "a3; some
  comment\r\n" Positions the stream at the start of the next line.
  @param stream The new input stream.
  @return The chunk size as integer
  @throws IOException when the chunk size could not be parsed