List of utility methods to do UTF8
byte[] | getUtf8Bytes(String s) Convinient method to get UTF8 bytes return s.getBytes(Charset.forName("UTF-8")); |
byte[] | GetUtf8Bytes(String str, boolean replace) Encodes a string in UTF-8 as a byte array. return GetUtf8Bytes(str, replace, false);
|
byte[] | getUTF8Bytes(String string) Converts the string to bytes using the UTF-8 encoding. try { return string.getBytes(UTF_8_CHARSET.name()); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); |
byte[] | getUTF8BytesFromString(String str) get UTF Bytes From String return str.getBytes(UTF_8);
|
CharsetDecoder | getUtf8Decoder() get Utf Decoder CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder(); decoder.onMalformedInput(CodingErrorAction.REPORT); decoder.onUnmappableCharacter(CodingErrorAction.REPORT); return decoder; |
Charset | getUtf8OrDefault() Returns the value of #getUtf8() if UTF8 is supported. if (Charset.isSupported(UTF8_NAME)) { return getUtf8(); } else { return Charset.defaultCharset(); |
Reader | getUTF8Reader(InputStream f) get UTF Reader BufferedInputStream bis = new BufferedInputStream(f); assert bis.markSupported(); bis.mark(3); boolean reset = true; byte[] t = new byte[3]; bis.read(t); if (t[0] == ((byte) 0xef) && t[1] == ((byte) 0xbb) && t[2] == ((byte) 0xbf)) { reset = false; ... |
String | getUtf8String(URL url) get Utf String try { return Resources.toString(url, UTF_8); } catch (IOException ex) { throw new UndeclaredThrowableException(ex); |
PrintStream | getUTF8SuportOutput() get UTF Suport Output PrintStream out = new PrintStream(System.out, true, "UTF-8"); return out; |
Writer | getUTF8Writer(String path) Returns a Writer for writing UTF-8 encoded data to the file at the specified path. FileOutputStream out = new FileOutputStream(path); OutputStreamWriter writer = null; try { writer = new OutputStreamWriter(out, _UTF8_ENCODING); } catch (UnsupportedEncodingException e) { assert false; return null; return new BufferedWriter(writer); |