JavaXT
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Extended File AttributesIn addition to the basic file attributes offered by the Java standard, javaxt.io.File and javaxt.io.Directory classes provide extended file attributes including Creation Date and Last Access Time. Here's a simple comparision of the capabilities offered by the javaxt-core library.
Last Access TimeKnowing when a file or directory was last accessed is a key attribute for monitoring and auditing file systems. This important attribute is available on both Windows and Unix/Linux file systems. The javaxt.io.File and javaxt.io.Directory classes both provide methods to retrieve the last access time. Here's an example of how to retrieve the last access time for a file: javaxt.io.File file = new javaxt.io.File("/temp/file.txt"); System.out.println("Accessed: " + file.getLastAccessTime()); Creation TimeKnowing when a file or directory was created is another key attribute. Unfortunately, not all file systems store this attribute. Most modern Linux and Windows file systems do store the creation time. Older UNIX systems (e.g. Solaris) do not. Here's an example of how you can retrieve the creation time for a file: javaxt.io.File file = new javaxt.io.File("/temp/file.txt"); System.out.println("Created: " + file.getCreationTime()); Content TypeThe javaxt.io.File includes a method to return the MIME type associated with a file extension. This method only covers the most common/popular MIME types. Here's an example: String contentType = new javaxt.io.File("/temp/file.txt").getContentType(); System.out.println(contentType); //returns "text/plain" Links and ShortcutsThe javaxt.io.File and javaxt.io.Directory classes include methods to determine whether a file is actually a link to another file (e.g. Symbolic link, Windows Junction, or Windows Shortcut). Users also have the ability to parse the link to retrieve the link target. Example: javaxt.io.File file = new javaxt.io.File("/temp/file.txt"); if (file.isLink()){ System.out.println(file.getLink()); } Additional File MetadataThe getFlags() method provides additional metadata values such as whether the file is encrypted or offline. Many of these attributes are specific to Microsoft File Systems (e.g. NTFS). A complete list of known flags follows this example. javaxt.io.File file = new javaxt.io.File("/temp/file.txt"); java.util.Iterator<String> it = file.getFlags().iterator(); while (it.hasNext()){ System.out.println(it.next()); } Known FlagsHere's a complete list of known flags published by Microsoft. Some of these are available for UNIX/Linux file systems as well (e.g. "READONLY", "HIDDEN", "DIRECTORY", "REPARSE_POINT", etc).
Reference |