Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.BitSet;

public class Main {
    static BitSet dontNeedEncoding;

    public static final boolean isURLEncoded(String str) {
        if (str == null || "".equals(str)) {
            return false;
        }
        char[] chars = str.toCharArray();
        boolean containsPercent = false;
        for (char c : chars) {
            if (Character.isWhitespace(c)) {
                return false;
            }
            if (!dontNeedEncoding.get(c)) {
                return false;
            }
            if (c == '%') {
                containsPercent = true;
            }
        }
        if (!containsPercent) {
            return false;
        }
        return true;
    }
}