return open stream to caller in walk
This commit is contained in:
parent
94cea9ae79
commit
99406c1ca4
2 changed files with 5 additions and 3 deletions
|
@ -120,14 +120,16 @@ public interface FileService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replacement for Files.walk() without AccessDeniedException.
|
* Replacement for Files.walk() without AccessDeniedException.
|
||||||
|
* Caller must use a try-with-resources statement.
|
||||||
|
*
|
||||||
* @param p the path
|
* @param p the path
|
||||||
* @return a stream of readable files under the path
|
* @return a stream of readable files under the path
|
||||||
*/
|
*/
|
||||||
static Stream<Path> walk(Path p) {
|
static Stream<Path> walk(Path p) {
|
||||||
if (Files.isReadable(p)) {
|
if (Files.isReadable(p)) {
|
||||||
if (Files.isDirectory(p)) {
|
if (Files.isDirectory(p)) {
|
||||||
try (Stream<Path> stream = Files.list(p)) {
|
try {
|
||||||
return stream.flatMap(FileService::walk);
|
return Files.list(p).flatMap(FileService::walk);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logger.getLogger(FileService.class.getName())
|
Logger.getLogger(FileService.class.getName())
|
||||||
.log(Level.FINE,"skipped " + p + " because of " + e.getMessage());
|
.log(Level.FINE,"skipped " + p + " because of " + e.getMessage());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
group = org.xbib
|
group = org.xbib
|
||||||
name = files
|
name = files
|
||||||
version = 4.2.0
|
version = 4.2.1
|
||||||
|
|
||||||
org.gradle.warning.mode = ALL
|
org.gradle.warning.mode = ALL
|
||||||
|
|
Loading…
Reference in a new issue