Skip to main content

Scanning a Folder

To scan an entire folder, use scanFolder. This walks the folder recursively using a thread pool and returns a list of JSON result strings — one per processed batch of files:
import com.scanoss.Scanner;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = Scanner.builder().build();
        List<String> results = scanner.scanFolder("src/");
        results.forEach(System.out::println);
    }
}

Scanning a Specific List of Files

To scan a subset of files rather than an entire folder, use scanFileList. Pass the root path of your project and a list of file paths relative to that root:
import com.scanoss.Scanner;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = Scanner.builder().build();
        List<String> files = List.of("src/Main.java", "src/Utils.java");
        List<String> results = scanner.scanFileList("/path/to/project", files);
        results.forEach(System.out::println);
    }
}

Generating Winnowing Fingerprints (WFP) Without Scanning

You can generate Winnowing Fingerprints (WFP) locally without making any network requests to the API. This is useful for auditing fingerprint output before submission, or for use in air-gapped environments:
import com.scanoss.Scanner;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = Scanner.builder().build();

        // Fingerprint a single file
        String wfp = scanner.wfpFile("/path/to/file.java");
        System.out.println(wfp);

        // Fingerprint an entire folder
        List<String> wfps = scanner.wfpFolder("/path/to/project");
        wfps.forEach(System.out::println);
    }
}
To use a premium API key or configure a custom API endpoint, see the Authentication page.