0

how can be done in java, to check string to prompt error when

  • string have special characters which have an EBCDIC value greater than hexadecimal “3F” or
  • an ASCII value greater than hexadecimal “1F”. Occurrences of values EBCDIC “00” - “3F” and ASCII “00” - “1F” are not valid.

sorry if my question repeated or confuse

Thanks in advance

1
  • 1
    What did you try, where are you stuck? Commented Jan 29, 2014 at 10:35

1 Answer 1

0

You can sort the String as is explained in this answer: Sort a single String in Java

char[] chars = original.toCharArray();
Arrays.sort(chars);

Once is sorted you only have to check that the last one in the array of chars is higher than your given hex value.

For EBCDIC you can add a comparator to the sort and order based on the EBCDIC instead.

    char[] chars = original.toCharArray();

    // I will convert my array of chars to array of Characters to use Arrays.sort   
    int length = Array.getLength(chars);


    Character[] ret = new Character[length];
    for(int i = 0; i < length; i++)
        ret[i] = (Character)Array.get(chars, i);

        // and now the important bit 
    Arrays.sort(ret, new Comparator<Character>() {

        @Override
        public int compare(Character arg0, Character arg1) {
            // convert arg0 and arg1 to EBCDIC with whatever tools you have
            return arg0InEBCDIC - arg1InEDBCIC;
        }
    });

Once you have an ordered array you just need to check the last element as I said.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.