@Override
        public boolean hasNext() {
            if (!sb.isEmpty()) return true;
            try {
                for (int r; (r = reader.read()) != -1; ) {
                    if (r < 0x20 || r >= 0x7F) {
                        if (sb.isEmpty()) continue; // Still haven't encountered any real data
                        if (sb.length() > 5) break; // We (probably) found some real data
                        sb.setLength(0); // Probably some random binary data that happened to be a printable character, reset
                    } else sb.append((char) r);
                }
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return !sb.isEmpty();
        }
Extracts sequences longer than 5 printable characters from a binary file, similar to `strings` command
node-repository/src/test/java/com/yahoo/vespa/hosted/provision/RealDataScenarioTest.java