Here you can find the source of encode(String encoding, String text)
Parameter | Description |
---|---|
encoding | a parameter |
text | a parameter |
public static byte[] encode(String encoding, String text)
//package com.java2s; import java.io.UnsupportedEncodingException; public class Main { /**/*www . j a v a2 s . c o m*/ * Encodes a String from unicode to the specified encoding. This method * returns null if the encoding is not supported * * @param encoding * @param text * @return byte[] */ public static byte[] encode(String encoding, String text) { if (text != null) { if (encoding == null) return text.getBytes(); try { return text.getBytes(encoding); } catch (UnsupportedEncodingException e) { } } return null; } }