Java

Watching A Directory for Changes — File Change Notification in NIO.2

Here is a sneak peek of the NIO.2 file coverage I am writing for the Java Tutorial. This will be available in the web push of the tutorial that coincides with the upcoming J1 Preview Release. (NIO.2 is part of the JDK 7 release.) -- Sharon Zakhour Have you ever found yourself editing a file, using an IDE or another editor, and a dialog pops up to inform you that one of the open files has changed on the file system and needs to be reloaded? Or perhaps, like the NetBeans IDE,it...

Wednesday, May 13, 2009 | Java | Read More

Converting Pre-JDK7 File I/O Code

Prior to JDK7, the java.io.File class was the mechanism used for file I/O, but it had several drawbacks: Many methods didn't throw exceptions when they failed, so it was impossible to get a useful error message. For example, if a file delete failed, the program would receive a "delete fail" but wouldn't know if it was because the file didn't exist, the user didn't have permissions, or if there was some other problem. The rename method didn't work consistently across platforms. T...

Wednesday, April 1, 2009 | Java | Read More

Deploying An Applet In Under 10 Minutes

JavaTM SE 6u10 allows us to deploy applets using Java Network Launch Protocol (JNLP). In fact, this is now a recommended best practice! Tired of dealing with pesky browser issues when deploying applets? Think Deployment Toolkit.           We now have the Deployment Toolkit, a JavaScript library with nifty functions to deploy applets and Java Web Start applications. It takes care of all underlying browser idiosyncracies :-) Check it out at http://java.com/js/deployJava.js or http...

Tuesday, March 31, 2009 | Java | Read More

PathMatcher in NIO.2

In my last blog entry I show how to walk a file tree using a FileVisitor in a very simple Find example. Alan Bateman (the NIO.2 czar) suggested that, rather than use java.lang.String to match the file, I use the new PathMatcher API. Good idea. You can get the path matcher from the file system using this code: PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + pattern); where pattern is, in this case, supplied at the command line. At least two syntaxes are...

Friday, March 27, 2009 | Java | Read More

Traversing a file tree in NIO.2

Have you downloaded JDK7 and played with NIO.2 yet? NIO.2 offers many new I/O features, particularly in the area of files and file system APIs. (To those of you who think, I can't use JDK7 because I am on a Mac: So am I. What I did was to download VirtualBox for my Mac (it's free). This allows you to set up a virtual environment on your machine. You can then download OpenSolaris, Ubuntu, or even Windows (but OpenSolaris and Ubuntu are free). I wrote a simple example which you...

Tuesday, March 24, 2009 | Java | Read More
 

Visit the Oracle Blog

 

Contact Us

Oracle

Integrated Cloud Applications & Platform Services