Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String escapeURL(String link) {
        try {
            String path = link;
            path = java.net.URLEncoder.encode(path, "utf8");
            path = path.replace("%3A", ":");
            path = path.replace("%2F", "/");
            path = path.replace("+", "%20");
            path = path.replace("%23", "#");
            path = path.replace("%3D", "=");
            return path;
        } catch (Exception e) {
            link = link.replaceAll("\\[", "%5B");
            link = link.replaceAll("\\]", "%5D");
            link = link.replaceAll("\\s", "%20");
        }
        return link;
    }
}