src/org/nutz/lang/Streams.java
public static InputStream utf8filte(InputStream in) {
        try {
            if (in.available() == -1)
                return in;
            PushbackInputStream pis = new PushbackInputStream(in, 3);
            byte[] header = new byte[3];
            int len = pis.read(header, 0, 3);
            if (len < 1)
                return in;
            if (header[0] != UTF_BOM[0] || header[1] != UTF_BOM[1] || header[2] != UTF_BOM[2]) {
                pis.unread(header, 0, len);
            }
            return pis;
        }
        catch (IOException e) {
            throw Lang.wrapThrow(e);
        }
    }
public static InputStream utf8filte(InputStream in) {
        try {
            if (in.available() == -1)
                return in;
            PushbackInputStream pis = new PushbackInputStream(in, 3);
            byte[] header = new byte[3];
            int len = pis.read(header, 0, 3);
            if (len < 1)
                return in;
            if (header[0] != UTF_BOM[0] || header[1] != UTF_BOM[1] || header[2] != UTF_BOM[2]) {
                pis.unread(header, 0, len);
            }
            return pis;
        }
        catch (IOException e) {
            throw Lang.wrapThrow(e);
        }
    }
public static InputStream utf8filte ( InputStream in ) { try { if ( in . available ( ) == - 1 ) return in ; PushbackInputStream pis = new PushbackInputStream ( in , 3 ) ; byte [ ] header = new byte [ 3 ] ; int len = pis . read ( header , 0 , 3 ) ; if ( len < 1 ) return in ; if ( header [ 0 ] != UTF_BOM [ 0 ] || header [ 1 ] != UTF_BOM [ 1 ] || header [ 2 ] != UTF_BOM [ 2 ] ) { pis . unread ( header , 0 , len ) ; } return pis ; } catch ( IOException e ) { throw Lang . wrapThrow ( e ) ; } }
判断并移除UTF-8的BOM头
判断并移除UTF - 8的BOM头