Questions tagged [nio2]

NIO2 is an umbrella name for new features added to the original Java NIO package in the Java 1.7 release. Also referred to as "New I/O".

NIO.2 is an umbrella name for new features added to the original Java package in the Java 1.7 release. Also referred to as "New I/O".

  • Asynchronous Channels and Futures: A Channel that supports asynchronous I/O operations with implementations for sockets, server sockets and files.
  • Completion Handlers: The ability to register handlers that will be called on the completion of an asynchronous I/O event.
  • Asynchronous Channel Groups: A grouping of asynchronous channels for the purpose of resource sharing.
  • Asynchronous Multicast: Support for implementing asynchronous NIO I/O with callbacks for UDP multicast.
  • A New File System API for Java: Defines new interfaces and classes for the Java virtual machine to access files, file attributes, and file systems.

Articles and Tutorials

Note: This tag and wiki should be rolled into the nio tag.

173 questions
0
votes
1 answer

Problems with Watch Service API of nio2 class

I am using Watch Service API of nio.2 class to watch a specific directory in my project(OS platform Ubuntu 11.10). whenever a change is made, for eg if a new file is added named abc.json to the watched directory it first fires the CREATED event and…
0
votes
1 answer

HTML5: Is file change notification in the API?

I took a look at the HTML5 File API. I also looked at this tutorial for handling files using HTML5. Is there an API for file change notifications? I was hoping for something similar to the WatchService API in the Java NIO2 library.
braveterry
  • 3,724
  • 8
  • 47
  • 59
0
votes
0 answers

Perform atomic move operation, but throw if target exist

How can I get the JDK to perform an atomic move operation, but throw FileAlreadyExistsException if the target already exist ? My source and target are of type Path. I'm guaranteed that they both reside in the same folder (have same parent) thus they…
peterh
  • 18,404
  • 12
  • 87
  • 115
0
votes
0 answers

I receive a ChannelClosedException when trying to connect to localhost service

I have recently developed a small client server application for a customer. A windows executable adaptor provides a number of TCP sockets to interact with an external host, and my java(kotlin) client software is listening to those sockets and sends…
Kai
  • 2,145
  • 1
  • 20
  • 35
0
votes
1 answer

NIO2 Path Symbols Java

If I created a two paths such as: Path path3 = Paths.get("E:\\data"); Path path4 = Paths.get("E:\\user\\home"); And then make a new Path(relativePath) by using the relativize() method on the two paths, creating: "..\user\home" does the path…
0
votes
1 answer

AsynchronousFileChannel not creating subdirectories

Below program throws "java.nio.file.NoSuchFileException" when subdirecties doesnot exist in path. Could some one please help how can I acheive this ? I want to insert records in asyncronous way. public static void main(String[] args) { String…
santosh jk
  • 111
  • 1
  • 11
0
votes
1 answer

Java NIO based scalable non blocking TCP client server design: recommend way to send large response back to client

I am trying to implement a highly scalable server in java for the following usecase Client sends a request to server in a form of COMMAND PARAM Server can send a varying size response, from a few characters (10 bytes) to large text data (of size…
ankit Soni
  • 11
  • 3
0
votes
1 answer

Java Apache2 Log File Permission Denied

I'm trying to read the apache2 custom log files in the /var/log/apache2/my_site/access.log in a Java program. But i get a permission denied Excpetion. The code is working on the Winows OS, i can read the log file, but in Ubuntu, i cannot access the…
Java User
  • 23
  • 3
0
votes
1 answer

How to set file permissions using java NIO2 on Windows?

Are there any ways of setting file permissions using java8 NIO2 on Windows different from this? file.setReadable(false, false); file.setExecutable(false, false); file.setWritable(false, false);
0
votes
1 answer

Get getLastModifiedTime(path) in TimeUnit.Days

I am trying to get the number of days, after the last modification of a given file. Following code gives me 18135 when checked for a file which is just been modified. Code public class IOExamples { public static void main(String[] args) throws…
Sunil
  • 429
  • 1
  • 9
  • 25
0
votes
0 answers

How to get 'java.io.IOException No space left on device' using ZipFileSystem

I save several files in a zip file using Java's FileSystem. If there is not enough disk space I can not get java.io.IOException No space left on device and it behaves as if the zip file were created successfully. Here is a snippet from my…
Karsten R
  • 9
  • 3
0
votes
1 answer

Why can we change the file attributes of a read-only file in Java?

Consider the following code: import java.io.IOException; import java.nio.file.attribute.DosFileAttributeView; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.FileTime; import…
Nikos Tzianas
  • 633
  • 1
  • 8
  • 21
0
votes
0 answers

How to get ack use the nio?

How to use the NIO library to get the ACK field and use it to reconnect the sever problems . I've tried some way , but it doesn't work .
0
votes
1 answer

Java 7 Watch Service cannot detect events properly

I have created a watch service java application using nio2's WatchService for a Linux server whereby I have it watching some directories in a mounted NAS drive. The files will arrive by NFS, MQ or SFTP. I have read in other places stating that the…
S. Ong
  • 5
  • 4
0
votes
1 answer

Java ZipFileSystem does not retain physical order while traversing

Let's consider a very simple Java snippet: String pathUriStr = Paths.get(args[0]).toUri().toASCIIString(); URI zipUri = URI.create("jar:" + pathUriStr); FileSystem zip = null; try { zip = FileSystems.newFileSystem(zipUri,…
Michael-O
  • 18,123
  • 6
  • 55
  • 121