@Override
    public BencodeInteger parse(BufferedInputStream inputStream) throws IOException, BencodeParseException {
        readAndCheckFirstByte(inputStream);

        StringBuilder stringBuilder = new StringBuilder();
        int currentByte;
        while ((currentByte = inputStream.read()) > -1) {
            char currentChar = (char) currentByte;
            if (currentChar == getPostfix()){
                return getIntegerValue(stringBuilder.toString());
            } else {
                stringBuilder.append(currentChar);
            }
        }
        throw new InvalidFormatException();
    }