@Delimiter¶
Sets the delimiter for the ListObjects request used to query S3.
Declaration¶
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Delimiter {
String value();
}
Attributes¶
| Attribute | Type | Description |
|---|---|---|
value |
String |
The delimiter character or string |
Description¶
S3 uses delimiters to simulate a directory hierarchy within a flat key space.
The default delimiter is "/", which treats slashes in keys as directory
separators. @Delimiter allows changing this for keys that use a different
separator.
@Delimiter works on both immediate listing methods and @Recursive methods.
When used with @Recursive, the delimiter controls how the walk discovers
child prefixes at each level.
Examples¶
Flat listing with a custom delimiter¶
public interface Logs extends S3.Dir {
// Keys like "2025-01-15-access.log", "2025-01-15-error.log"
@Delimiter("-")
Stream<S3File> bySegment();
}
Recursive listing with a custom delimiter¶
public interface DateIndex extends S3.Dir {
// Keys like "2025-01-15", "2025-02-20"
// Delimiter "-" splits on hyphens, creating a year/month/day hierarchy
@Recursive
@Delimiter("-")
Stream<S3.Dir> byDate();
}
No delimiter¶
An empty string disables delimiter-based grouping entirely:
public interface Bucket extends S3.Dir {
// Returns all keys as a flat list, no directory grouping
@Delimiter("")
Stream<S3File> allKeys();
}
See Also¶
- @Recursive — recursive listing (defaults to
"/"delimiter for S3.Dir types) - Listing & Recursion — how delimiters affect listings