没有.decode或字节的url解码器

时间:2015-04-20 21:58:06

标签: java url decoder

我是java语言的新手,我正在大学学习,我的教授希望我们制作一个url解码器,而不使用内置命令,也没有内置的十六进制转换器。但我的问题是我将如何解析一个电子邮件地址,然后在%40插入@符号时停止,然后允许解析其余的URL更改+为空格。下面的代码是我到目前为止我只是坚持如何解码数组,所以没有标识符。此外,我是网站的新用户,对于任何格式提前抱歉,或者如果我要求太多,谢谢!

   import java.util.Scanner;
public class URLdecoder {
    @SuppressWarnings("unused")
    public static void main(String[] args){

        String URL = GetUrl();
        String[] URLtwo = decoder(URL);
        for(int i = 0; i<URLtwo.length;i++){
            System.out.println(URLtwo[i]);
        }
    }
    public static String GetUrl(){

        Scanner Keyboard = new Scanner(System.in);
        System.out.printf("Please input the url below!%n"); 
        String Input = Keyboard.nextLine();
        Keyboard.close();
        return Input;
    }
    @SuppressWarnings("unused")
    public static String[] decoder(String URL){
        String[] deUrl = null;
        String eliminator = "[?]";
        String[] threeUrl = null;
        deUrl = URL.split(eliminator);
        String elmintwo = "[&]+";
        for(int i = 0; i<deUrl.length;i++){
            threeUrl=deUrl[i].split(elmintwo);
        }
        return threeUrl;

    }
}

0 个答案:

没有答案