Questions on the NIO.2 API
martijnverburg at gmail.com
Mon Jan 31 07:30:33 PST 2011
I've finally come back to this Chapter and am thinking about the various
rough code samples I've written (running b127 on Windows XP SP3 32bit). My
next code sample simply takes the reader through some of the file system api
in order to explore some of the basics.
public class Listing_2_1
public static void main(String args) throws IOException
try (FileSystem fileSystem = FileSystems.getDefault())
Path backupDir = fileSystem.getPath("H:/projects/");
FileStore backupFileStore = backupDir.getFileStore();
throw new IOException("Suspicious storage type");
CopyOption copyOptions = StandardCopyOption.REPLACE_EXISTING;
The code example is a pretty patsy one, but one gotcha in particular was
noticed by earlier reviewers.
The FileStore object's type is simply a String as opposed to a constant,
enum or other defined type. This makes it very hard to rely on for decision
making (as per the if statement I have above). I assume this is a
limitation of being able to consistently detect the underlying storage type?
Thanks again all.
(@java7developer - twitter)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the nio-dev