nio2 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
4
Solved
I want to merge huge files containing strings into one file and tried to use nio2. I do not want to load the whole file into memory, so I tried it with BufferedReader:
public void mergeFiles(files...
1
Solved
The Files.write & Files.writeString methods in Java 7+ are a concise handy way to write text to a file.
try
{
Files.write (
Paths.get ( "/Users/My_UserName/Example.txt" ) ,
List.of...
4
Solved
The documentation for the overflow states:
OVERFLOW – Indicates that events might have been lost or discarded.
It does not say under what circumstance should I expect event to be lost or disc...
2
Solved
My server uses a AsynchronousServerSocketChannel that listens for client connections using a CompletionHandler. When a client connection is accepted, the AsynchronousSocketChannel is read, again us...
3
Solved
Is the following code thread-safe? If so, what guarantees the safe publication of the ByteBuffer instance to the thread executing the CompletionHandler?
AsynchronousSocketChannel channel = ...
Byte...
Hebephrenia asked 26/8, 2021 at 9:32
3
Solved
How to check that file exists inside a zip archive?
For example, check whether app.apk contains classes.dex.
I want to find a solution that uses Java NIO.2 Path and without extracting the whole arc...
Articular asked 7/9, 2015 at 10:3
4
Solved
I'm trying to find a way to detect when a flash drive has been plugged into my computer. So far, the solution I found was to poll FileSystem#getFileStores for changes. This does indeed tell me when...
2
I am using this WatchService example from Oracle:
import java.nio.file.*;
import static java.nio.file.StandardWatchEventKinds.*;
import static java.nio.file.LinkOption.*;
import java.nio.file.attr...
Caesaria asked 25/8, 2016 at 14:15
1
Solved
Java AsyncHttpClient: broken file while writing from LazyResponseBodyPart to AsynchronousFileChannel
I use AsyncHttpClient library for async non blocking requests.
My case: write data to a file as it is received over the network.
For download file from remote host and save to file I used default ...
Culpa asked 31/5, 2019 at 15:20
2
Solved
In the stream tutorial, nothing is said about closing streams gained from Files.newInputStream( path ). Only some obscure:
Whether the returned stream is asynchronously closeable and/or
interru...
2
Solved
This code searches for a specific file:
Stream<Path> findMyFile = Files.find(Paths.get("c:\\temp\\pathtest"), Integer.MAX_VALUE,(p, a) -> p.endsWith("test.txt") && a.isRegularFile...
2
All the sources/samples on the INTERNET that available on NIO2 are without TLS/SSL support,
java.nio.channels.AsynchronousSocketChannel
java.nio.channels.AsynchronousServerSocketChannel
As I unde...
4
Path file = Paths.get("c:/large.log");
AsynchronousFileChannel channel = AsynchronousFileChannel.open(file);
final ByteBuffer buffer = ByteBuffer.allocate(1000);
channel.read(buffer, 0, buffer,...
3
Solved
Is there a concise, idiomatic way (maybe using Apache Commons) to specify common combinations of OpenOption like StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXI...
8
Solved
Is there an API to get a classpath resource (e.g. what I'd get from Class.getResource(String)) as a java.nio.file.Path? Ideally, I'd like to use the fancy new Path APIs with classpath resources.
2
Solved
I want to split a huge file containing strings into a set of new (smaller) file and tried to use nio2.
I do not want to load the whole file into memory, so I tried it with BufferedReader.
The s...
1
I'm testing out the undertow 2.0.0.Alpha1 webserver. When I run it locally it works and returns Hello World when I go to localhost:80. I then deploy the webserver on a remote server and go to remot...
2
Solved
I have a file that I've been reading into a List via the following method:
List<String> doc = java.nio.file.Files.readAllLines(new File("/path/to/src/resources/citylist.csv").toPath(), Stand...
2
Solved
It seems that Files.newBufferedReader() is more strict about UTF-8 than the naive alternative.
If I create a file with a single byte 128---so, not a valid UTF-8 character---it will happily be read...
1
I'm confused... according to this Java page the File.setReadOnly() function is now a "legacy" function and should be replaced by Files.setAttribute()... but this requires you to know whether you ar...
0
How do I get the decoded data after the SSL Handshake is complete?
At the moment it seems to decrypt just some of the data.
Steps to reproduce
Save and Run this code
Go to https://localhost:150...
1
Solved
It's possible, although perhaps ill-advised, to read archive formats that are basically renamed .zip files (.ear, .war, .jar, etc.), by using the jar: URI scheme.
For example, the following code ...
3
The project I'm working has been using Java 6 and jpathwatch (.95) and is now upgrading to Java 7. Currently on Windows 7 and 2008 Server. I'm refactoring areas of code to use the new Java 7 NIO an...
Guardroom asked 2/10, 2013 at 15:1
4
I was looking for in-memory nio2 FileSystem implementations, that would allow me to more easily test my IO-dependent code.
It seems natively, Java only provides (in my JDK) a Win32FileSystem and a...
Hydrated asked 20/10, 2012 at 11:50
1 Next >
© 2022 - 2024 — McMap. All rights reserved.