17 questions
0
votes
0
answers
45
views
How to List pdf filenames [duplicate]
I cannot get a list of files ending with .pdf, I have tried everything, it lists everything else in the folder, except for the pdf's, what is wrong with this. The program then displays the list in a
...
0
votes
1
answer
253
views
Copying multiple files from one folder to another in JAVA 15
Path src = Paths.get("./resources");
Path dst = Paths.get("./trash");
try {
DirectoryStream<Path> ds = Files.newDirectoryStream(src);
...
1
vote
1
answer
306
views
Java NIO Read Folder's content's attributes at once
I'm writing a backup program using Java and the package NIO.
As far as I found, I could do it as in the code example below, i.e. read the folder content list and then for each file I have to do file ...
3
votes
4
answers
3k
views
List all Files from a Directory that match a File Mask (a.k.a Pattern or Glob)
I want to list all files in a directory and subdirectories within that directory that match a file mask.
For example "M:\SOURCE\*.doc" while SOURCE may look like this:
|-- SOURCE
| |-- ...
2
votes
2
answers
829
views
List directory content with Project Reactor and DirectoryStream
I'd like to use DirectoryStream with Project Reactor to list all the files in a directory.
My try is:
Path myDir = Paths.get("C:\\Users\\r.dacanal\\Documents\\Reply\\EDA\\logging-consumer\\input");
...
2
votes
2
answers
1k
views
Java - Count all file extensions in a folder using DirectoryStream
I would like to show all file extensions in a specific folder and give the total for each extension using DirectoryStream.
Now I'm only showing all the files in that folder, but how do I get their ...
1
vote
0
answers
151
views
Directly read a specific subdirectory from a zip file [Java]
I would like to directly read the files from a subdirectory which is in a zip file.
Is there a more convenient way to do it without iterating through all entries?
The structure of the zip file is ...
5
votes
1
answer
5k
views
DirectoryStream return path in what kind of order? filename, last modified, filesize?
I am trying to read multiple files in a folder using DirectoryStream. There are 10 items altogether.
doc_01.txt, doc_02.txt, doc_03.txt, doc_04.txt, doc_05.txt, doc_06.txt, doc_07.txt, doc_08.txt, ...
0
votes
1
answer
519
views
How to calculate number of documents per hour depending on their "last modified"
I'm working on a tool to count archived files from another program. Therefor I'm using the DirectoryStream and filter subdirectories and some files with a simple if-clause (shown below).
For the ...
0
votes
1
answer
1k
views
Java FileVisitor visit ordered in a directory
I am trying to use the Java's FileVisitor interface to walk through a list of files and import the contents onto a database. The scenario is to import the csv contents in order. There may be a file ...
0
votes
0
answers
55
views
Java on Macintosh directoryStream shows Applications as Folders
I feel like I must be missing something. It seems like this should be really easy but I can't seem to find an answer to this question.
I'm writing code in Java 8 using both
Files.newDirectoryStream()...
1
vote
1
answer
3k
views
How to use Java's directory stream to get files/subdirectories only within directory not other subdirectories
I'm using Java's DirectoryStream to get a list of all the files/subfolders in a directory. However, after going through all the files and folders of the directory, my code then proceeds to go through ...
2
votes
1
answer
2k
views
In Java 8 Stream API, what's the difference between a DirectoryStream<Path> and Stream<Path>?
I want to return a stream of paths (these are files located in a certain directory). My initial approach was this:
DirectoryStream getFiles(Path dir) throws IOException {
Files.newDirectoryStream(...
0
votes
0
answers
348
views
Deleting empty folders in Java, dealing with hidden files
I am trying to delete empty folders in java, here is my code:
try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
for (Path file : stream) {
if (file....
0
votes
0
answers
862
views
Files.newDirectoryStream with filter recursive [duplicate]
I had the following code:
Path dir = Paths.get("My root dir/Folder1");
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*.xml")) {
for (Path entry : stream) {
...
1
vote
3
answers
3k
views
How does "try-with-resources" actually work in the context of this program that deletes all files and folders below a given directory node
This program deletes all files and folders beneath a given node.
*EDIT*
I have the following "test" directory structure on drive K:
Folder K:\garbage\
f_00000b (file)
f_00000f ( " )
f_0000b3 ( " )
...
45
votes
9
answers
89k
views
Recursively list all files within a directory using nio.file.DirectoryStream;
I want to list all the FILES within the specified directory and subdirectories within that directory. No directories should be listed.
My current code is below. It does not work properly as it only ...