Java String Encode encode(String encoding, String string)

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

Description

encode

License

Apache License

Declaration

public static byte[] encode(String encoding, String string) throws UnsupportedEncodingException 

Method Source Code


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

import java.io.UnsupportedEncodingException;

public class Main {
    public static byte[] encode(String encoding, String string) throws UnsupportedEncodingException {
        if (encoding == null) {
            return string.getBytes();
        } else {//from   ww  w. ja  v a  2 s .  c  o  m
            return string.getBytes(encoding);
        }
    }
}

Related

  1. encode(final String s)
  2. encode(final String s)
  3. encode(final String s, final String encoding)
  4. encode(final String source, final String encoding, BitSet notEncoded)
  5. encode(String data, String encode)
  6. encode(String encoding, String text)
  7. encode(String name)
  8. encode(String s)
  9. encode(String s)