Locale { @Pure public static String decodeString(byte[] bytes) { final Charset[] prior = getPriorizedDecodingCharsets(); final String refBuffer = new String(bytes); CharBuffer buffer = null; for (final Charset charset : prior) { buffer = decodeString(bytes, charset, refBuffer.length()); if (buffer != null) { break; } } if (buffer == null) { for (final Charset charset : Charset.availableCharsets().values()) { buffer = decodeString(bytes, charset, refBuffer.length()); if (buffer != null) { break; } } } if (buffer == null) { return refBuffer.trim(); } return buffer.toString().trim(); } private  Locale(); static Charset[] getPriorizedDecodingCharsets(); static void setPriorizedDecodingCharsets(Charset[] charsets); @Pure @Inline(value = "Locale.getStringWithDefaultFrom(ClassLoaderFinder.findClassLoader(), ($1), ($2), ($3), ($4))", imported = {Locale.class, ClassLoaderFinder.class}) static String getStringWithDefaultFrom(String resourcePath, String key, String defaultValue, Object... params); @Pure static String getStringWithDefaultFrom(ClassLoader classLoader, String resourcePath, String key,
			String defaultValue, Object... params); @Pure @Inline(value = "Locale.getStringWithDefaultFrom(($1), ($2), ($3), ($4))", imported = {Locale.class}) static String getStringFrom(String resourcePath, String key, Object... params); @Pure @Inline(value = "Locale.getStringWithDefaultFrom(($1), ($2), ($3), ($3), ($4))", imported = {Locale.class}) static String getStringFrom(ClassLoader classLoader, String resourcePath, String key, Object... params); @Pure static String getString(Class<?> resource, String key, Object... params); @Pure static String getString(ClassLoader classLoader, Class<?> resource, String key, Object... params); static String getString(String key, Object... params); @Pure static String getString(ClassLoader classLoader, String key, Object... params); @Pure static String getStringWithDefault(Class<?> resource, String key, String defaultValue, Object... params); @Pure static String getStringWithDefault(ClassLoader classLoader, Class<?> resource, String key,
			String defaultValue, Object... params); @Pure static String getStringWithDefault(String key, String defaultValue, Object... params); @Pure static String getStringWithDefault(ClassLoader classLoader, String key, String defaultValue, Object... params); @Pure static String decodeString(byte[] bytes); static String decodeString(InputStream stream); static boolean decodeString(InputStream stream, List<String> lineArray);  }
@Test public void decodeStringByteArray() { byte[] bytes = new byte[] {80, 104, 111, 116, 111, 103, 114, 97, 109, 109, -126, 116, 114, 105, 101, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32}; String str = Locale.decodeString(bytes); assertEquals("Photogrammétrie", str); }