EncodingUtils { public static String getAutoDecodedString(byte[] data, String defaultEncoding) throws IOException { return new String(data, detectEncoding(data, defaultEncoding)); }  static String getAutoDecodedString(byte[] data, String defaultEncoding); static String detectEncoding(byte[] data, String defaultEncoding); static String encodePathWithUTF8(String path); static String decodePathWithUTF8(String path);  }
@Test public void testGetAutoDecodedString() throws IOException { String testStr = "12345678ikbsdfghjklsdfghjklzxcvbnm,.:LGF)(&^%^RYVG"; String rtnEncode = EncodingUtils.detectEncoding(testStr.getBytes("UTF-8"), "UTF-8"); assertThat(rtnEncode, is("UTF-8")); }