Java URL Decode decode(String encodeMsg)

Here you can find the source of decode(String encodeMsg)

Description

decode

License

Apache License

Declaration

public static String decode(String encodeMsg) 

Method Source Code


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

import java.io.UnsupportedEncodingException;

public class Main {
    public static String decode(String encodeMsg) {
        try {/*  w w w .  j  a  v  a2  s .c  o  m*/
            String transMsg = new String(encodeMsg.getBytes("ISO-8859-1"), "UTF-8");
            return java.net.URLDecoder.decode(transMsg, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static String[] decode(String[] ecodeMsgs) {
        String[] result = new String[ecodeMsgs.length];
        try {
            for (int i = 0; i < ecodeMsgs.length; i++) {
                String transMsg = new String(ecodeMsgs[i].getBytes("ISO-8859-1"), "UTF-8");
                result[i] = java.net.URLDecoder.decode(transMsg, "UTF-8");
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return result;
    }
}

Related

  1. decode(final String s, final String enc)
  2. decode(final String string)
  3. decode(Object value)
  4. decode(String content)
  5. decode(String encoded)
  6. decode(String input)
  7. decode(String input)
  8. decode(String path)
  9. decode(String path, String encoding)