question: protected String consumeBOM ( InputStream stream , String encoding ) throws IOException { byte [ ] b = new byte [ 3 ] ; int count = 0 ; stream . mark ( 3 ) ; if ( encoding . equals ( "UTF-8" ) ) { count = stream . read ( b , 0 , 3 ) ; if ( count == 3 ) { final int b0 = b [ 0 ] & 0xFF ; final int b1 = b [ 1 ] & 0xFF ; final int b2 = b [ 2 ] & 0xFF ; if ( b0 != 0xEF || b1 != 0xBB || b2 != 0xBF ) { stream . reset ( ) ; } } else { stream . reset ( ) ; } } else if ( encoding . startsWith ( "UTF-16" ) ) { count = stream . read ( b , 0 , 2 ) ; if ( count == 2 ) { final int b0 = b [ 0 ] & 0xFF ; final int b1 = b [ 1 ] & 0xFF ; if ( b0 == 0xFE && b1 == 0xFF ) { return "UTF-16BE" ; } else if ( b0 == 0xFF && b1 == 0xFE ) { return "UTF-16LE" ; } } stream . reset ( ) ; } return encoding ; }
target:  Removes the byte order mark from the stream, if it exists and returns the encoding name.