get Invalid URI Char - Android Network

Android examples for Network:Uri

Description

get Invalid URI Char

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        String s = "java2s.com";
        System.out.println(getInvalidURIChar(s));
    }/*from www  .j  a v a2 s  . c om*/

    public static int getInvalidURIChar(String s) {
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z')
                    && (c < '0' || c > '9')
                    && ";/?:@&=+$,-_.!~*'()%".indexOf(c) < 0)
                return i;
        }
        return -1;
    }
}

Related Tutorials