Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

ASCII character check using loop

I am tried for ASCII escape sequence using for loop, something I missed while checking Here is code where I am getting Parser exception. :

final int LEN_TYPE = 4;
final char[] temp = new char[LEN_TYPE];
        boolean charAllowed = true;
        for (int i = 0; i < LEN_TYPE; ++i) {
            final int read = in.read();
            if (!(read == ' ' && i > 0
                    || charAllowed && read >= 'A' && read <= 'Z'))
                throw new HeaderParseException(in.getSource(),
                        in.getPosition(),
                        i == 0 ? "A-Z" : charAllowed ? "A-Z or ' '" : "' '",
                        read);
            temp[i] = (char) read;
            if (read == ' ')
                charAllowed = false;
        }
        return new MntSvcType(String.valueOf(temp, 0, LEN_TYPE),
                MntSvcMessage.class);

My question is even though passing the ASCII range why I need to check again for ESC and I am also using Ansi then why I need to check ESC again

Comments