Java URL Encode encode(String raw)

Here you can find the source of encode(String raw)

Description

Encode the message by replacing all the white spaces with %20.

License

BSD License

Parameter

Parameter Description
raw Output data from the RESOLVE compiler.

Return

The encoded data for WebIDE.

Declaration

public static String encode(String raw) 

Method Source Code


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

import java.io.UnsupportedEncodingException;

import java.net.URLEncoder;

public class Main {
    /**//from   w w  w  .  ja va  2 s . c om
     * <p>Encode the message by replacing all the white spaces with %20.</p>
     *
     * @param raw Output data from the RESOLVE compiler.
     *
     * @return The encoded data for WebIDE.
     */
    public static String encode(String raw) {
        String encoded = null;

        try {
            encoded = URLEncoder.encode(raw.replaceAll(" ", "%20"), "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

        return encoded;
    }
}

Related

  1. encode(String _string, String _sEncoding)
  2. encode(String from, String to, String word)
  3. encode(String in)
  4. encode(String input)
  5. encode(String input)
  6. encode(String s)
  7. encode(String s)
  8. encode(String s)
  9. encode(String s)