Java String Encode encodeForm(Map form)

Here you can find the source of encodeForm(Map form)

Description

encode Form

License

Open Source License

Declaration

public static String encodeForm(Map<String, Object> form) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Map;
import java.util.Map.Entry;

public class Main {
    public static String encodeForm(Map<String, Object> form) {
        try {/*w  ww.  ja  v  a  2s. c o  m*/
            StringBuilder result = new StringBuilder();
            for (Entry<String, Object> argument : form.entrySet()) {
                result.append(URLEncoder.encode(argument.getKey(), "UTF-8"));
                result.append('=');
                result.append(URLEncoder.encode(String.valueOf(argument.getValue()), "UTF-8"));
                result.append('&');
            }
            result.deleteCharAt(result.length() - 1);
            return result.toString();
        } catch (UnsupportedEncodingException e) {
            throw new IllegalStateException(e);
        }
    }
}

Related

  1. encodeDoublePercent(String input)
  2. encodeDownloadFileName(String s)
  3. encodeFilename(final String filename, final String userAgent)
  4. encodeFilename(String filename, String encoding)
  5. encodeFilenameOmittingWhiteSpaces(String filename, String encoding)
  6. encodeIncludingSpecialCharacters(String toEncode)
  7. encodeInternally(String s)
  8. encodeJobHistoryFileName(String logFileName)
  9. encodeMap(Map map, String enc)