question: public static boolean isBinaryFile ( final IScope scope , final File f ) { if ( f == null || ! f . exists ( ) ) return false ; byte [ ] data ; try ( FileInputStream in = new FileInputStream ( f ) ) { int size = in . available ( ) ; if ( size > 1024 ) size = 1024 ; data = new byte [ size ] ; in . read ( data ) ; int ascii = 0 ; int other = 0 ; for ( int i = 0 ; i < data . length ; i ++ ) { final byte b = data [ i ] ; if ( b < 0x09 ) return true ; if ( b == 0x09 || b == 0x0A || b == 0x0C || b == 0x0D ) ascii ++ ; else if ( b >= 0x20 && b <= 0x7E ) ascii ++ ; else other ++ ; } if ( other == 0 ) return false ; return 100 * other / ( ascii + other ) > 95 ; } catch ( final IOException e ) { GAMA . reportAndThrowIfNeeded ( scope , GamaRuntimeException . error ( "Problem determining the type of " + f . getPath ( ) , scope ) , false ) ; return false ; } }
target:  Guess whether given file is binary. Just checks for anything under 0x09.