List of utility methods to do InputStream Encoding Get
String | getStreamEncoding(InputStream is) get Stream Encoding BufferedInputStream bis = new BufferedInputStream(is); bis.mark(2); byte[] first3bytes = new byte[3]; bis.read(first3bytes); bis.reset(); String encoding = null; if (first3bytes[0] == (byte) 0xEF && first3bytes[1] == (byte) 0xBB && first3bytes[2] == (byte) 0xBF) { ... |
String | getStreamEncoding(InputStream is) get Stream Encoding BufferedInputStream bis = new BufferedInputStream(is); bis.mark(2); byte[] first3bytes = new byte[3]; bis.read(first3bytes); bis.reset(); String encoding = null; if (first3bytes[0] == (byte) 0xEF && first3bytes[1] == (byte) 0xBB && first3bytes[2] == (byte) 0xBF) { ... |
String | getEncodingFromHTML(InputStream is) get Encoding From HTML final int FIND_CHARSET_CACHE_SIZE = 4 * 1024; BufferedInputStream bis = new BufferedInputStream(is); bis.mark(FIND_CHARSET_CACHE_SIZE); byte[] cache = new byte[FIND_CHARSET_CACHE_SIZE]; bis.read(cache); bis.reset(); return getHtmlCharset(new String(cache)); |