Java examples for java.lang:String Unicode
encoding By ISO-8859-1
//package com.java2s; import java.io.UnsupportedEncodingException; public class Main { public static void main(String[] argv) { String string = "java2s.com"; System.out.println(encodingByISO8859_1(string)); }/*from w w w. j a v a 2 s.c om*/ public static String encodingByISO8859_1(String string) { if ((string != null) && !("".equals(string))) { try { return new String(string.getBytes(), "ISO-8859-1"); } catch (UnsupportedEncodingException e) { return string; } } return string; } }