java.nio.file Questions
4
Solved
If I want to do something with files only on the first level of the directory,
is there a difference between using Files.list(...) or Files.walkFileTree(...) or Files.walk(...)?
Files.walkFileTree...
Chromaticness asked 16/6, 2016 at 11:38
2
How should you handle a FileSystemAlreadyExistsException when calling FileSystems.newFileSystem?
One way would be to use the already created FileSystem (getFileSystem), but then you could run int...
Speiss asked 28/4, 2019 at 16:37
3
Solved
In one of my projects I have concurrent write access to one single file within one JRE and want to handle that by first writing to a temporary file and afterwards moving that temp file to the targe...
Bentonbentonite asked 11/8, 2014 at 7:54
4
I have a piece of code that monitors a directory for addition of files. Whenever a new file is added to the directory, the contents of the file are picked and published on kafka and then the file i...
Tackett asked 24/11, 2016 at 6:46
4
Solved
I'd like to use Google's JIMFS for creating a virtual file system for testing purposes. I have trouble getting started, though.
I looked at this tutorial: http://www.hascode.com/2015/03/creating-in...
Jiggermast asked 10/4, 2015 at 12:10
6
I want to watch a directory for file changes. And I used WatchService in java.nio. I can successfully listen for file created event. But I can't listen for file modify event. I checked official jav...
Kassi asked 4/5, 2014 at 4:13
3
I'm using Spring Boot and have the following Component class:
@Component
@ConfigurationProperties(prefix="file")
public class FileManager {
private Path localDirectory;
public void setLocalDir...
Cartridge asked 25/6, 2015 at 18:40
3
Solved
I have a SpringBoot 2.0.1.RELEASE mvc application.
In the resources folder I have a folder named /elcordelaciutat.
In the controller I have this method to read all the files inside the folder
Cla...
Postbellum asked 11/4, 2018 at 11:57
2
Solved
What is the order in which Files.walkFileTree visits files/directories at the same level?
It doesn't appear to visit them in order of size, last modified time or name. I couldn't find anything in ...
Tapp asked 1/5, 2012 at 10:47
5
Solved
I was learning java nio package and I realized there are lots of methods already provided by File which nio.Files is providing again by using Path class. Like that few more I got.
I am actually not...
Undeniable asked 29/4, 2012 at 12:17
1
I want to delete one file and rename another file with the old file but I am not able to move this file as java is throwing java.nio.file.FileAlreadyExistsException Following is the code snippet I ...
Indigene asked 9/6, 2016 at 9:15
1
Solved
I have generated a Stream in Java 8 with Files.walk() method from java.nio library. The problem is that the method includes by default the root path but I do not want this element. I have solved in...
Benedic asked 30/3, 2017 at 15:18
3
Solved
I am trying to read a large file line by line, in java, using NIO library.
But this file also contains headers...
try (Stream<String> stream = Files.lines(Paths.get(schemaFileDir + File...
Mornings asked 21/12, 2016 at 7:54
1
Solved
I am trying to use methods from java.nio.file.* to perform some basic file operations in a Jenkins pipeline. Regardless of the node block in which the code exists, the code executes on the master n...
Terse asked 28/9, 2016 at 17:9
5
Solved
For my application, I have to write a method that takes an InputStream as argument, writes the content to a temporary file, performs some operations and finally deletes the temporary.
This is what...
Shaner asked 2/12, 2015 at 17:36
3
Solved
I'm unable to think of a realistic use case for the method java.io.File.exists() or its equivalent in Java 7 java.nio.file.Files.exists(Path). It seems that isFile() or isDirectory() would be prefe...
Trill asked 11/12, 2013 at 15:33
1
Solved
I've been playing around with the java.nio.file.WatchService and noticed that the Paths returned from WatchEvent.context() does not return correct .toAbsolutePath(). Here is an example application:...
Josephinajosephine asked 21/9, 2015 at 9:10
1
Solved
I am trying to create a JMeter load test. I need the test to take a sample log file and change its name. The only way I could find to do this was to copy the file in a BeanShell Preprocessor but I ...
Hypochlorite asked 25/8, 2015 at 10:51
1
Solved
I am using Java version 1.8.0_31.
I am trying to recursively access a directory tree using the FileVisitor interface.
The program should print the name of all files in C:/books whose file name sta...
Samovar asked 10/5, 2015 at 21:57
2
Solved
Recently I was doing some coding using the java.nio.file package introduced in Java 7 and saw an example using Path like this:
Path path = Paths.get("C:\\Users");
Given that Path is an interfac...
Vexillum asked 30/12, 2013 at 8:44
1
Solved
This bug is present in the latest 1.7 and 1.8 versions of the JDK (7u72, 8u25). Required: jackson-databind 2.5.0. Tested on Linux x86_64 (Ubuntu 14.10 to be precise).
Code:
public static void mai...
Backscratcher asked 14/1, 2015 at 23:50
1
NOTE: Please run the exact code below; no adaptations of it, in particular, do not use File, as this bug is tied to the new java.nio.file API
OK, this is not really a "question which is in need of...
Extenuatory asked 6/12, 2014 at 2:51
3
Solved
The javadoc for .isAbsolute() says:
Tells whether or not this path is absolute.
An absolute path is complete in that it doesn't need to be combined with other path information in order to locat...
Kitsch asked 29/11, 2014 at 12:24
1
I have encountered a bug where one of our server applications was using more and more memory every second pretty much and I have managed to filter out a short example that still shows that behavior...
Judon asked 9/12, 2014 at 15:4
1
Solved
I am attempting to use createFile with a FileAttribute derived from "rw-rw-rw-". My file is being created as "rw-rw-r--" on Fedora.
How can I set OTHERS_WRITE when creating a file?
Example:
(-&...
Trivet asked 28/8, 2014 at 19:10
1 Next >
© 2022 - 2024 — McMap. All rights reserved.