Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (c)  Subhra Das Gupta
 *
 * This file is part of Xtream Download Manager.
 *
 * Xtream Download Manager is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * Xtream Download Manager is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with Xtream Download Manager; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

public class Main {
    public static String decode(String str) {
        char ch[] = str.toCharArray();
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < ch.length; i++) {
            if (ch[i] == '/' || ch[i] == '\\' || ch[i] == '"' || ch[i] == '?' || ch[i] == '*' || ch[i] == '<'
                    || ch[i] == '>' || ch[i] == ':')
                continue;
            if (ch[i] == '%') {
                if (i + 2 < ch.length) {
                    int c = Integer.parseInt(ch[i + 1] + "" + ch[i + 2], 16);
                    buf.append((char) c);
                    i += 2;
                    continue;
                }
            }
            buf.append(ch[i]);
        }
        return buf.toString();
    }
}