Java String Encode encode(String val, String encoding)

Here you can find the source of encode(String val, String encoding)

Description

encode

License

Open Source License

Declaration

public static String encode(String val, String encoding) throws UnsupportedEncodingException 

Method Source Code

//package com.java2s;
/**/*from w w  w  .j a v a 2 s  .  c o  m*/
  * Copyright 2010 ZTEsoft Inc. All Rights Reserved.
  *
  * This software is the proprietary information of ZTEsoft Inc.
  * Use is subject to license terms.
  * 
  * $Tracker List
  * 
  * $TaskId: $ $Date: 9:24:36 AM (May 9, 2008) $comments: create 
  * $TaskId: $ $Date: 3:56:36 PM (SEP 13, 2010) $comments: upgrade jvm to jvm1.5 
  *  
  *  
  */

import java.io.*;

public class Main {

    public static String encode(String val, String encoding) throws UnsupportedEncodingException {
        if (val == null) {
            return null;
        }
        return new String(val.getBytes(encoding));
    }

    public static String encode(String val, String formEncoding, String toEncoding)
            throws UnsupportedEncodingException {
        if (val == null) {
            return null;
        }
        return new String(val.getBytes(formEncoding), toEncoding);
    }
}

Related

  1. encode(String str)
  2. encode(String str, int start, int end, Writer writer)
  3. encode(String text, String charset)
  4. encode(String text, String encoding)
  5. encode(String text, String encoding)
  6. encode(String value, String encoding)
  7. encodeBase64(String str)
  8. encodeConvenience(String str)
  9. encodeDataPair(final StringBuilder buffer, final String key, final String value)