package study.try_catch;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
public class TryCatchMain {
public static void main(String[] args) throws Exception {
byte[] bs = toGBK("中文");
System.out.println(Arrays.toString(bs));
byte[] bs2=toGBK2("中文");
System.out.println(Arrays.toString(bs2));
}
static byte[] toGBK(String s) throws UnsupportedEncodingException {
return s.getBytes("GBK");
}
static byte[] toGBK2(String s) {
try {
return s.getBytes("GBK");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
}