Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import java.util.StringTokenizer;

public class Main {
    public static String decodePath(String path, String delimiter, String characterSet)
            throws UnsupportedEncodingException {
        final StringTokenizer tokenizer = new StringTokenizer(path, delimiter);
        final StringBuilder builder = new StringBuilder(path.length());

        while (tokenizer.hasMoreTokens()) {
            builder.append(URLDecoder.decode(tokenizer.nextToken(), characterSet));
            builder.append(delimiter);
        }
        builder.delete(builder.length() - delimiter.length(), builder.length());
        return builder.toString();
    }
}