As with every new Java version, Java 7 introduced some new features. The new features are definitely worth the change and as developers, we must be happy as we can be more efficient. There are many features introduced in Java 7 but we will look at some of them. Allows Strings to be used in …
java 7
FileStore in Java 7
FileStore is new class introduced in Java 7.0. It is part of java.nio package. This class helps in geting the type of storage for the files stored whether it’s a device, partition or concreate file system. Also this class defines the list of methods which is useful for getting information about the file storage such …
Reading file asynchronously in Java
We all are familiar with reading/writing file in a synchronous way. In Java 7 a new API was added to read/write the contents of the file asynchronously. The API is AsynchronousFileChannel. also read: Java 7.0 Tutorials New Features in Java 7.0 G1 Garbage Collector in Java 7.0 In this example lets look at how to …
Visiting all the files and directories for a directory in Java using NIO2
At times we might want to search for some file in a directory traversing recursively into other directories with in that directory, I know getting the recursive program right at the first time is always a challenge. Or we might want to list all the contents of a directory. For all these operations the NIO2 …
Listing and filtering directory content using Java NIO2
The Files class provides a method- newDirectoryStream to get the Directory contents for a give path instance. There are other overloaded versions of newDirectoryStream method which take in filters to apply on the directory content. also read: Java 7.0 Tutorials New Features in Java 7.0 G1 Garbage Collector in Java 7.0 Listing all files in …
Creating Hard links and Soft links for a file in Java
We have been exploring the NIO enhancements in Java 7 and in this post I will explain about creating links- Hard links and Soft links in Java. And this feature is part of Java 7. also read: Java 7.0 Tutorials New Features in Java 7.0 G1 Garbage Collector in Java 7.0 A link is kind …
Obtaining and modifying the metadata of the files in Java 7 NIO.2
Files usually contain information like its creation time, last modified time, last accessed time, size, type, permissions, ownership and other details which constitute its metadata. NIO.2 enhancements in Java 7 adds views to obtain metadata information of the file. The file attributes are grouped into different views based on their relatedness and applicability, for example …
Exploring the Path API – Java NIO enhancement in Java 7
All of us know that an instance of File doesn’t indicate a file in the file system, unless some one invokes a create or related methods. But its a kind of confusion- you talk about instance of File and then you also talk about file at the disk level. A new class was introduced in …