Example usage for java.net URLDecoder decode

List of usage examples for java.net URLDecoder decode

Introduction

In this page you can find the example usage for java.net URLDecoder decode.

Prototype

public static String decode(String s, Charset charset) 

Source Link

Document

Decodes an application/x-www-form-urlencoded string using a specific java.nio.charset.Charset Charset .

Usage

From source file:cn.edu.xmu.comm.action.json.TempParkingBillAddAction.java

public String execute() {
    try {//from w  ww.j ava 2s.co  m
        license = URLDecoder.decode(license, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    data = new HashMap<String, Object>();
    Boolean hasFreeParkPlace = parkingService.hasFreeTempParkPlace();
    Boolean hasOwner = propertyService.hasOwner(ownerId);
    data.put("hasFreeParkPlace", hasFreeParkPlace ? "true" : "false");
    data.put("hasOwner", hasOwner ? "true" : "false");
    if (hasFreeParkPlace && hasOwner) {
        Integer parkBillId = parkingService.addParkBill(ownerId, license).getId();
        data.put("parkBillId", parkBillId.toString());
    }
    return SUCCESS;
}

From source file:com.mycollab.common.UrlEncodeDecoder.java

/**
 * @param str/*from   w  w  w. ja v a  2  s  .c  om*/
 * @return
 */
public static String decode(String str) {
    try {
        String decodeStr = URLDecoder.decode(str, "UTF8");
        decodeStr = new String(Base64.decodeBase64(decodeStr.getBytes("UTF-8")), "UTF-8");
        return decodeStr;
    } catch (Exception e) {
        LOG.error("Error while decode string: " + str);
        return "";
    }
}

From source file:net.chris54721.infinitycubed.Updater.java

private static void downloadUpdate(String version) {
    try {//ww w . jav  a2  s .c om
        // TODO Trigger splashscreen progressbar (run downloadable w/custom ProgressListener)
        File executable = new File(URLDecoder.decode(
                (Launcher.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()),
                "UTF-8"));
        String extension = FilenameUtils.getExtension(executable.getName());
        File updateTemp = new File(Reference.DEFAULT_FOLDER, "update." + extension);
        Downloadable update = new Downloadable(
                new URL(Reference.UPDATE_URL + extension + "/infinitycubed-" + version + "." + extension),
                updateTemp);
        if (update.download()) {
            executable.delete();
            FileUtils.moveFile(updateTemp, executable);
            Utils.restart();
        } else
            LogHelper.warn("Failed downloading launcher update: file size not matching.");
    } catch (Exception e) {
        LogHelper.error("Failed downloading launcher update", e);
    }
}

From source file:com.hp.autonomy.frontend.find.hod.converter.StringToResourceIdentifierConverter.java

private String decodeUriComponent(final String part) {
    try {/*from  w  ww .j  a  v a  2  s.c  o  m*/
        return URLDecoder.decode(part, "UTF-8");
    } catch (final UnsupportedEncodingException e) {
        throw new AssertionError("All JVMs must support UTF-8", e);
    }
}

From source file:com.alacoder.lion.common.utils.StringTools.java

public static String urlDecode(String value) {
    if (StringUtils.isBlank(value)) {
        return "";
    }/*from   ww  w.  java  2 s  .c  o  m*/
    try {
        return URLDecoder.decode(value, LionConstants.DEFAULT_CHARACTER);
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:com.weibo.api.motan.util.StringTools.java

public static String urlDecode(String value) {
    if (StringUtils.isBlank(value)) {
        return "";
    }/*from   w  ww.j ava2 s.  c o  m*/
    try {
        return URLDecoder.decode(value, MotanConstants.DEFAULT_CHARACTER);
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:com.esofthead.mycollab.common.UrlEncodeDecoder.java

/**
 * // w ww.  jav a  2 s. c  om
 * @param str
 * @return
 */
static String decode(String str) {
    try {
        String decodeStr = URLDecoder.decode(str, "UTF8");
        decodeStr = new String(Base64.decodeBase64(decodeStr.getBytes("UTF-8")), "UTF-8");
        return decodeStr;
    } catch (Exception e) {
        LOG.error("Error while decode string: " + str);
        return "";
    }
}

From source file:com.ai.smart.common.helper.util.RequestUtils.java

/**
 * ?QueryString?URLDecoderUTF-8??post??//  w  w  w .  jav a  2  s.com
 * HttpServletRequest#getParameter?
 *
 * @param request web
 * @param name    ???
 * @return
 */
public static String getQueryParam(HttpServletRequest request, String name) {
    if (StringUtils.isBlank(name)) {
        return null;
    }
    if (request.getMethod().equalsIgnoreCase(POST)) {
        return request.getParameter(name);
    }
    String s = request.getQueryString();
    if (StringUtils.isBlank(s)) {
        return null;
    }
    try {
        s = URLDecoder.decode(s, UTF8);
    } catch (UnsupportedEncodingException e) {
        log.error("encoding " + UTF8 + " not support?", e);
    }
    String[] values = parseQueryString(s).get(name);
    if (values != null && values.length > 0) {
        return values[values.length - 1];
    } else {
        return null;
    }
}

From source file:codes.thischwa.c5c.util.StringUtils.java

public static String decode(String str) {
    try {/*  ww  w.ja va 2s . co m*/
        return URLDecoder.decode(str, PropertiesLoader.getDefaultEncoding());
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.system.util.encode.EncodeUtils.java

/**
 * URL ?, EncodeUTF-8. /*  w  w  w  .j  a  va 2  s  . co m*/
 */
public static String urlDecode(String input) {
    try {
        return URLDecoder.decode(input, EncodeUtil.ENCODE);
    } catch (UnsupportedEncodingException e) {
        throw new IllegalArgumentException("Unsupported Encoding Exception", e);
    }
}