public static boolean isBinaryFile(File file) throws IOException {
        InputStream in = null;
        try {
            in = new FileInputStream(file);
            int size = file.length() > 500 ? 500 : new Long(file.length()).intValue();
            byte[] bytes = new byte[size];

            in.read(bytes, 0, bytes.length);
            short bin = 0;
            for (byte thisByte : bytes) {
                char it = (char) thisByte;
                if (!Character.isWhitespace(it) && !Character.isISOControl(it)) {
                    bin++;
                }

                if (bin >= 5) {
                    return true;
                }
            }
        } finally {
            if (in != null) {
                in.close();
            }
        }

        return false;
    }