Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Java 7 New Features Cookbook
Java 7 New Features Cookbook
Credits
About the Authors
Acknowledgement
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Instant Updates on New Packt Books
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Java Language Improvements
Introduction
Using string literals in switch statements
Getting ready
How to do it...
How it works...
There's more...
Using underscores in literals to improve code readability
Getting ready
How to do it...
How it works...
There's more...
Simple underscore usage mistakes
Using underscores with hexadecimal literals
Using underscores with binary literals
Using the try-with-resources block to improve exception handling code
Getting ready
How to do it...
How it works...
There's more...
Understanding suppressed exceptions
Structuring issues when using the try-with-resources technique
See also
Creating a resource that can be used with the try-with-resources technique
Getting ready
How to do it...
How it works...
There's more...
See also
Catching multiple exception types to improve type checking
Getting ready
How to do it...
How it works...
There's more...
The use of a common exception base class and the ReflectiveOperationException
Using the AssertionError class in Java 7
See also
Rethrowing exceptions in Java 7
Getting ready
How to do it...
How it works...
See also
Using the diamond operator for constructor type inference
Getting ready
How to do it...
How it works...
There's more...
Using the diamond operator when the type is not obvious
Suppressing unchecked warnings
Understanding erasure
Using the @SafeVarargs annotation
Getting ready
How to do it...
How it works...
There's more...
The use of @SafeVarargs annotation in Java core libraries
An example of heap pollution
See also
2. Locating Files and Directories Using Paths
Introduction
Creating a Path object
Getting ready
How to do it...
How it works...
There's more...
Using the Paths class' get method
The meaning of the parent path
See also
Interoperability between java.io.File and java.nio.file.Files
Getting ready
How to do it...
How it works...
See also
Converting a relative path into an absolute path
Getting ready
How to do it...
How it works...
There's more...
See also
Removing redundancies by normalizing a path
Getting ready
How to do it...
How it works...
There's more...
See also
Combining paths using path resolution
Getting ready
How to do it...
How it works...
There's more...
Using a String argument with the resolve method
Improper use of the resolve method
Using the resolveSibling
See also
Creating a path between two locations
Getting ready
How to do it...
How it works...
There's more...
Both paths are equal
One path contains a root
Both paths contain a root
See also
Converting between path types
Getting ready
How to do it...
How it works...
There's more...
Determining whether two paths are equivalent
Getting ready
How to do it...
How it works...
There's more...
See also
Managing symbolic links
Getting ready
How to do it...
How it works...
See also
3. Obtaining File and Directory Information
Introduction
Determining the file content type
Getting ready
How to do it...
How it works...
There's more...
Obtaining a single attribute at a time using the getAttribute method
Getting ready
How to do it...
How it works...
There's more...
Obtaining a map of file attributes
Getting ready
How to do it...
How it works...
There's more...
Getting file and directory information
Getting ready
How to do it...
How it works...
There's more...
Determining operating system support for attribute views
Getting ready
How to do it...
How it works...
There's more...
Using the supportsFileAttributeView method with a class argument
Using the supportsFileAttributeView method with a String argument
Maintaining basic file attributes using the BasicFileAttributeView
Getting ready
How to do it...
How it works...
There's more...
Maintaining POSIX file attributes using the PosixFileAttributeView
Getting ready
How to do it...
How it works...
There's more...
See also
Maintaining FAT table attributes using the DosFileAttributeView
Getting ready
How to do it...
How it works...
See also
Maintaining file ownership attributes using the FileOwnerAttributeView
Getting ready
How to do it...
How it works...
See also
Maintaining a file's ACL using the AclFileAttributeView
Getting ready
How to do it...
How it works...
There's more...
See also
Maintaining user-defined file attributes using the UserDefinedFileAttributeView
Getting ready
How to do it...
How it works...
There's more...
4. Managing Files and Directories
Introduction
Creating files and directories
Getting ready
How to do it...
How it works...
There's more...
Using the createDirectories method to create a hierarchy of directories
See also
Controlling how a file is copied
Getting ready
How to do it...
How it works...
There's more...
Copying a symbolic link file
Copying a directory
Copying an input stream to a file
Copying a file to an output stream
See also
Managing temporary files and directories
Getting ready
How to do it...
How it works...
There's more...
Setting time-related attributes of a file or directory
Getting ready
How to do it...
How it works...
There's more...
Understanding the FileTime class
Using the Files class' setLastModifiedTime to maintain the last modified time
Using the Files class' setAttribute method to set individual attributes
See also
Managing file ownership
Getting ready
How to do it...
How it works...
There's more...
Using the Files class' setOwner method
Managing ACL file permissions
Getting ready
How to do it...
How it works...
There's more...
Managing POSIX attributes
Getting ready
How to do it...
How it works...
There's more...
Removing a file permission
Modifying the POSIX ownership of a file
Using the Files class' set/get POSIX file permission methods
Using the Files class' setAttribute method
Using the PosixFilePermissions class to create PosixFilePermissions
Moving a file and a directory
Getting ready
How to do it...
How it works...
There's more...
Trivial uses of the move method
The meaning of the StandardCopyOption enumeration values
Using the resolveSibling method with the move method to affect a rename operation
Moving a directory
Deleting files or directories
Getting ready
How to do it...
How it works...
There's more...
Managing symbolic links
Getting ready
How to do it...
How it works...
There's more...
Creating a hard link
Creating a symbolic link to a directory
Determining the target of a link file
5. Managing Filesystems
Introduction
Getting FileStore information
Getting ready
How to do it...
How it works...
See also
Getting Filesystem information
Getting ready
How to do it...
How it works...
There's more...
Using the SimpleFileVisitor class to traverse filesystems
Getting ready
How to do it...
How it works...
There's more...
See also
Deleting a directory using the SimpleFileVisitor class
Getting ready
How to do it...
How it works...
See also
Copying a directory using the SimpleFileVisitor class
Getting ready
How to do it...
How it works...
See also
Processing the contents of a directory by using the DirectoryStream interface
Getting ready
How to do it...
How it works...
There's more...
See also
Filtering a directory using globbing
Getting ready
How to do it...
How it works...
There's more...
Using the PathMatcher interface to filter a directory
See also
Writing your own directory filter
Getting ready
How to do it...
How it works...
See also
Monitoring file events using WatchEvents
Getting ready
How to do it...
How it works...
There's more...
Understanding the ZIP filesystem provider
Getting ready
How to do it...
How it works...
See also
6. Stream IO in Java 7
Introduction
Managing simple files
Getting ready
How to do it...
How it works...
There's more...
Writing to a simple file
Reading all of the lines of a file returned as a list
See also
Using buffered IO for files
Getting ready
How to do it...
How it works...
There's more...
Writing to a file using the BufferedWriter class
Un-buffered IO support in the Files class
See also
Random access IO using the SeekableByteChannel
Getting ready
How to do it...
How it works...
There's more...
Processing the contents of the entire file
Writing to a file using the SeekableByteChannel interface
Query the position
See also
Managing asynchronous communication using the AsynchronousServerSocketChannel class
Getting ready
How to do it...
How it works...
There's more...
Using the Future object in a server
Understanding the AsynchronousServerSocketChannel class options
See also
Writing to a file using the AsynchronousFileChannel class
Getting ready
How to do it...
How it works...
There's more...
See also
Reading from a file using the AsynchronousFileChannel class
Getting ready
How to do it...
How it works...
There's more...
See also
Using the SecureDirectoryStream class
Getting ready
How to do it...
How it works...
There's more...
7. Graphical User Interface Improvements
Introduction
Mixing heavyweight and lightweight components
Getting ready
How to do it...
How it works...
There's more...
Managing window types
Getting ready
How to do it...
How it works...
Managing the opacity of a window
Getting ready
How to do it...
How it works...
There's more...
See also
Creating a varying gradient translucent window
Getting ready
How to do it...
How it works...
See also
Managing the shape of a window
Getting ready
How to do it...
How it works...
See also
Using the new border types in Java 7
Getting ready
How to do it...
How it works...
Handling multiple file selection in the FileDialog class
Getting ready
How to do it...
How it works...
There's more...
Controlling the print dialog box type
Getting ready
How to do it...
How it works...
Using the new JLayer decorator for a password field
Getting ready
How to do it...
How it works...
There's more...
8. Handling Events
Introduction
Managing extra mouse buttons and high resolution mouse wheels
Getting ready
How to do it...
How it works...
There's more...
Controlling a focus when displaying a window
Getting ready
How to do it...
How it works...
There's more...
Using secondary loops to mimic modal dialog boxes
Getting ready
How to do it...
How it works...
There's more...
See also
Handling spurious thread wakeups
Getting ready
How to do it...
How it works...
Handling applet initialization status with event handlers
Getting ready
How to do it...
How it works...
9. Database, Security, and System Enhancements
Introduction
Using the RowSetFactory class
Getting ready
How to do it...
How it works...
There's more...
Java 7 database enhancements
Getting ready
How to do it...
How it works...
There's more...
Retrieving pseudo-columns
Controlling the type value of the OUT parameter
Other database enhancements
Using the ExtendedSSLSession interface
Getting ready
How to do it...
How it works...
Using the platform MXBeans for JVM or system process load monitoring
Getting ready
How to do it...
How it works...
There's more...
Using the getPlatformMXBeans method
Obtaining the platform's management interfaces
Redirecting input and output from operating system's processes
Getting ready
How to do it...
How it works...
There's more...
Using the ProcessBuilder.Redirect class
Using the inheritIO method to inherit the default IO locations
Embedding a JNLP file in an HTML page
Getting ready
How to do it...
How it works...
10. Concurrent Processing
Introduction
Using join/fork framework in Java
Getting ready
How to do it...
How it works...
There's more...
See also
Using the reusable synchronization barrier Phaser
Getting ready
How to do it...
How it works...
There's more...
Using a phaser to repeat a series of tasks
See also
Using the new ConcurrentLinkedDeque safely with multiple threads
Getting ready
How to do it...
How it works...
There's more...
Problems with asynchronous concurrent threads
Adding elements to the deque
Retrieving elements from the deque
Accessing a specific element of the deque
Using the new LinkedTransferQueue class
Getting ready
How to do it...
How it works...
There's more...
Problems with asynchronous concurrent threads
Adding elements to the queue
Retrieving elements from the deque
Supporting multiple threads using the ThreadLocalRandom class
Getting ready
How to do it...
How it works...
There's more...
See also
11. Odds and Ends
Introduction
Unicode 6.0
Primitive types and the compare method
Global logger
JavaDocs improvements
JVM performance enhancements
Handling weeks in Java 7
Getting ready
How to do it...
How it works...
There's more...
Using the Currency class in Java 7
Getting ready
How to do it...
How it works...
Using the NumericShaper.Range enumeration to support the display of digits
Getting ready
How to do it...
How it works...
There's more...
JavaBean enhancements in Java 7
Getting ready
How to do it...
How it works...
There's more...
Handling locales and the Locale.Builder class in Java 7
Getting ready
How to do it...
How it works...
There's more...
Using the Locale.Category enumeration to display information using two different locales
Handling null references
Getting ready
How to do it...
How it works...
There's more...
Additional Objects class methods
Using empty iterators to avoid null pointer exceptions
Using the new BitSet methods in Java 7
Getting ready
How to do it...
How it works...
There's more...
← Prev
Back
Next →
← Prev
Back
Next →