List of usage examples for java.lang String String
String(byte[] value, byte coder)
From source file:Main.java
public static String GBK2ISO(String str) { String ret = null;/*from ww w .ja v a2s. c om*/ try { ret = new String(str.getBytes("GBK"), "ISO-8859-1"); } catch (Exception e) { ret = "GBK2ISO error. str=" + str; } return (ret); }
From source file:Main.java
public static String ISO2UTF8(String str) { String ret = null;/* ww w .j av a 2 s . c o m*/ try { ret = new String(str.getBytes("ISO-8859-1"), "UTF-8"); } catch (Exception e) { ret = "ISO2UTF8 error. str=" + str; } return (ret); }
From source file:Main.java
public static String convertToUTF8(String s) { String out = null;/*from w ww . ja v a2 s . c om*/ try { out = new String(s.getBytes("UTF-8"), "ISO-8859-1"); } catch (java.io.UnsupportedEncodingException e) { return null; } return out; }
From source file:Main.java
public static String getString(byte[] bytes, String charsetName) { return new String(bytes, Charset.forName(charsetName)); }
From source file:Main.java
public static int stringSize(String s) { try {/*from w w w . ja v a 2s . c o m*/ String anotherString = new String(s.getBytes("GBK"), "ISO8859_1"); return anotherString.length(); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); return 0; } }
From source file:Main.java
public static String readUTF(byte[] data) { try {/*from w w w . j a v a 2s. c o m*/ return new String(data, "UTF-8"); } catch (UnsupportedEncodingException ex) { } return ""; }
From source file:Main.java
public static String bytesToString(byte[] bytes) { try {//from w w w . j ava 2 s . co m return new String(bytes, "ASCII"); } catch (Exception ex) { return ex.toString(); } }
From source file:Main.java
public static String encodeByte(byte[] strbyte, String destEncoding) { String ret = null;//from ww w . ja va 2 s.c o m try { ret = new String(strbyte, destEncoding); } catch (Exception e) { ret = "byte to " + destEncoding + " error. str=[" + strbyte + "]"; } return (ret); }
From source file:Main.java
public static String byteToString(byte[] bytes) { return new String(bytes, Charset.defaultCharset()); }
From source file:Main.java
public static String utf8StringFromBytes(byte[] bytes) { try {//from w w w.j a v a 2 s . c o m return new String(bytes, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; }