Here you can find the source of getBytes(String data, String encoding)
Parameter | Description |
---|---|
data | a parameter |
encoding | a parameter |
public static byte[] getBytes(String data, String encoding)
//package com.java2s; import java.io.UnsupportedEncodingException; public class Main { /**//www. ja va 2 s.c o m * Convert a string to an array of bytes, representing the string in the * given encoding. This works like {@link String#getBytes(String)}, but if * the encoding is unknown, the resulting {@Llink UnsupportedEncodingException} * is wrapped in a {@link RuntimeException}. * * @param data * @param encoding * @return */ public static byte[] getBytes(String data, String encoding) { try { return data.getBytes(encoding); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } }