Skip to content

io microsphere io scanner SimpleFileScanner

github-actions[bot] edited this page Mar 21, 2026 · 1 revision

SimpleFileScanner

Type: Class | Module: microsphere-java-core | Package: io.microsphere.io.scanner | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/io/scanner/SimpleFileScanner.java

Overview

Simple File Scanner (Single-Thread)

This class provides a simple mechanism to scan files and directories using customizable filters. It supports both recursive and non-recursive scanning operations.

Features

- Scans files and directories based on provided filters.
- Supports recursive scanning of subdirectories.
- Returns an unmodifiable set of matched files, preserving order based on the underlying file system's implementation.

Example Usage

`// Scan all files in the given directory (non-recursive)
Set files = SimpleFileScanner.INSTANCE.scan(new File("/your/path"), false);

// Scan all files recursively under the given directory
Set recursiveFiles = SimpleFileScanner.INSTANCE.scan(new File("/your/path"), true);

// Scan with custom filter (e.g., only .txt files)
IOFileFilter filter = new IOFileFilter() {
    public boolean accept(File file) {
        return file.getName().endsWith(".txt");
    `
};
Set txtFiles = SimpleFileScanner.INSTANCE.scan(new File("/your/path"), true, filter);
}

Declaration

public class SimpleFileScanner

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.1.10-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

// Scan all files in the given directory (non-recursive)
Set<File> files = SimpleFileScanner.INSTANCE.scan(new File("/your/path"), false);

// Scan all files recursively under the given directory
Set<File> recursiveFiles = SimpleFileScanner.INSTANCE.scan(new File("/your/path"), true);

// Scan with custom filter (e.g., only .txt files)
IOFileFilter filter = new IOFileFilter() {
    public boolean accept(File file) {
        return file.getName().endsWith(".txt");
    }
};
Set<File> txtFiles = SimpleFileScanner.INSTANCE.scan(new File("/your/path"), true, filter);

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.io.scanner.SimpleFileScanner;

API Reference

Public Methods

Method Description
scan Singleton
scan Scan all File Set that are accepted by IOFileFilter under root directory

Method Details

scan

public Set<File> scan(File rootDirectory, boolean recursive)

Singleton / public final static SimpleFileScanner INSTANCE = new SimpleFileScanner();

public SimpleFileScanner() { }

/** Scan all File Set under root directory

scan

public Set<File> scan(File rootDirectory, boolean recursive, IOFileFilter ioFileFilter)

Scan all File Set that are accepted by IOFileFilter under root directory

See Also

  • SimpleFileScanner#INSTANCE
  • IOFileFilter

This documentation was auto-generated from the source code of microsphere-java.

Home

java-annotations

java-core

jdk-tools

lang-model

annotation-processor

java-test

Clone this wiki locally