|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FEEDS SEARCH LINKS CONTACT jaya_hangal Template by Helquin |
Thursday Feb 16, 2006
Check out what Mustang offers in the I/O libraries
Mustang release has small but very useful enhancements in the core libraries area. Here is a brief look at some of them in the I/O area that you must have heard about during the JavaOne 2005 talk given by Mark Reinhold. Free Diskspace: One can now discover the amount of disk space left in the partition named by the given file. This is one of the highly voted RFE (697 votes). This is a very handy feature, for example, installers can now determine beforehand how much diskspace is available on a partition that it's going to install the stuff on. Three new methods have been added to java.io.File class: getFreeSpace() getUsableSpace() getTotalSpace() Using these methods one can do something like: import java.io.*; : : : File dir; System.out.println("Total MB Free Usable"); System.out.format(" %6d %6d %6d\n", (dir.getTotalSpace() >> 20), (dir.getFreeSpace() >> 20), (dir.getUsableSpace() >> 20)); Changing File Attributes: In Mustang the java.io.File API provides access to the file attributes for changing its readability, ability to write and ability to make it executable. Check out the following methods for playing around with file attributes: Changing readability:   owner-only, owner or everybody Making it writable or read-only:  owner-only, owner or everybody Making it executable or not executable: owner-only, owner or everybody Password Prompting: This is one of the highly voted RFE (438 votes) as well, that fixed the good old problem of password input being echoed on a system console. This is useful for command line tools that accept password from system console, eg: keytool. The new class java.io.Console enables reading the password from the console without echoing it. Here is a small code snipped that shows this: import java.io.*; : : Console cons; char[] passwd = null; if ((cons = System.console()) != null) passwd = cons.readPassword("[%s]", "Password:"); : : Posted at 08:17AM Feb 16, 2006 by jaya_hangal in Java | Comments[1] |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Posted by 192.18.42.10 on February 16, 2006 at 08:49 AM PST #