Java Virtal Machine.net

[ News ] rss

February 01, 2011

Mark Wielaard: New GPG key. Finally created a new GPG key using gnupg. The old one was a DSA/1024 bits one and 8 years old. The new one is a RSA/2048 bits one. I will use the new one in the future to sign any release tarballs I might create. pub 2048R/57816A6A 2011-01-29 Key f...

More »

February 01, 2011

Andrew Hughes: [SECURITY] IcedTea6 1.7.8, 1.8.5, 1.9.5 Released!. We are pleased to announce a new set of security releases, IcedTea6 1.7.8, IcedTea6 1.8.5 and IcedTea6 1.9.5. This update contains the following security updates: The IcedTea project provides a harness to build the source code from OpenJDK6 u...

More »

November/2024
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17 181920212223
24252627282930
       

[ Archives News
for 'Java Technology' ]

home > news > java technology > introducing nio.2 (jsr 203) part 3: file system attributes and permissions support in nio.2

Introducing NIO.2 (JSR 203) Part 3: File System Attributes and Permissions support in NIO.2

 In two previous entries I covered Introducing NIO.2 (JSR 203) Part 1: What are new features?  and Introducing NIO.2 (JSR 203) Part 2: The Basics  In this entry I will discuss Attributes introduced in NIO.2. Using attributes we can read platform specific attributes of an element in the file system. For example to hide a file system in DOS file system or to check the last access date of a file in a UNIX machine. Using NIO.2 we can check which attributes are supported in the platform we are running on and then we can decide how to deal with the available attributes. Following sample code shows how we can detect the available attributes and then how to manipulate them. FileSystem fs = FileSystems.getDefault(); Path p = fs.getPath("/home/masoud/netbeans-6.9-ml-linux.sh"); //checking available attributes: Set supportedViews = fs.supportedFileAttributeViews(); //We always have at least one member in the set, the basic view. BasicFileAttributes ba = p.getFileAttributeView(BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS).readAttributes(); //Printing some basic attributes System.out.println(p.toString() + " last access: " + ba.lastAccessTime()); System.out.println(p.toString() + " last modified " + ba.lastModifiedTime()); // As I know I am in NIX machine I access the unix attributes. // If I didnt I should have iterate over the set to determine which // attributes are su...


Date: June, 23 2010
Url: http://www.java.net/blog/kalali/archive/2010/06/23/introducing-nio2-jsr-203-part-3-file-system-attributes-and-permission


Others News

©2002-2019Java-Virtual-Machine.net pt | Free Templates | bootstrap buttons | bootstrap popup window | css3 menu