Limit search to available items
Book Cover
E-book
Author Juneau, Josh, author

Title Java 8 recipes / Josh Juneau
Edition Second edition
Published Berkeley, CA : Apress, 2014
New York, NY : Distributed to the Book trade worldwide by Springer
©2014
Online access available from:
Springer eBooks    View Resource Record  

Copies

Description 1 online resource (xliv, 800 pages) : illustrations
Series The expert's voice in Java
Expert's voice in Java.
Contents Machine generated contents note: ch. 1 Getting Started with Java 8 -- 1-1. Creating a Development Environment -- Problem -- Solution -- How It Works -- 1-2. Getting to "Hello, World" -- Problem -- Solution -- How It Works -- 1-3. Compiling and Executing from the Command-line Interpreter -- Problem -- Solution -- How It Works -- 1-4. Declaring Simple Variables -- Problem -- Solution -- How It Works -- 1-5. Converting to and from a String -- Problem -- Solution -- How It Works -- 1-6. Passing Arguments via Command-Line Execution -- Problem -- Solution -- How It Works -- 1-7. Accepting Input from the Keyboard -- Problem -- Solution -- How It Works -- 1-8. Documenting Your Code -- Problem -- Solution -- How It Works -- 1-9. Organizing Code with Packages -- Problem -- Solution -- How It Works -- 1-10. Configuring the CLASSPATH -- Problem -- Solution -- How It Works -- 1-11. Reading Environment Variables -- Problem -- Solution -- How It Works -- Summary -- ch. 2 New Features of Java 8 -- Java Language Enhancements -- 2-1. Passing Functionality as a Method Argument -- Problem -- Solution -- How It Works -- 2-2. Calling On an Existing Method from a Lambda Expression -- Problem -- Solution -- How It Works -- 2-3. Providing a Default Method Implementation in an Interface -- Problem -- Solution -- How It Works -- 2-4. Applying the Same Annotation Multiple Times in a Declaration or Type Use -- Problem -- Solution -- How It Works -- Date-Time API -- 2-5. Incorporating the Current Date and Time -- Problem -- Solution -- How It Works -- 2-6. Obtaining a Date from a Specified String -- Problem -- Solution -- How It Works -- 2-7. Performing Date-Time Calculations -- Problem -- Solution -- How It Works -- Streams API -- 2-8. Iterating Over a Collection of Data -- Problem -- Solution -- How It Works -- JavaFX -- 2-9. Embedding Swing in JavaFX -- Problem -- Solution -- How It Works -- 2-10. Adding a DatePicker -- Problem -- Solution -- How It Works -- 2-11. Printing from JavaFX -- Problem -- Solution -- How It Works -- Scripting -- 2-12. Embedding JavaScript in Your Java Application -- Problem -- Solution -- How It Works -- 2-13. Executing JavaScript from the Command-Line -- Problem -- Solution -- How It Works -- Summary -- ch. 3 Strings -- 3-1. Obtaining a Subsection of a String -- Problem -- Solution -- How It Works -- 3-2. Comparing Strings -- Problem -- Solution -- How It Works -- 3-3. Trimming Whitespace -- Problem -- Solution -- How It Works -- 3-4. Changing the Case of a String -- Problem -- Solution -- How It Works -- 3-5. Concatenating Strings -- Problem -- Solution #1 -- Solution #2 -- Solution #3 -- How It Works -- 3-6. Converting Strings to Numeric Values -- Problem -- Solution #1 -- Solution #2 -- How It Works -- 3-7. Iterating Over the Characters of a String -- Problem -- Solution -- How It Works -- 3-8. Finding Text Matches -- Problem -- Solution #1 -- Solution #2 -- How It Works -- 3-9. Replacing All Text Matches -- Problem -- Solution -- How It Works -- 3-10. Determining Whether a File Name Ends with a Given String -- Problem -- Solution -- How It Works -- Summary -- ch. 4 Numbers and Dates -- 4-1. Rounding Float and Double Values to Integers -- Problem -- Solution -- How It Works -- 4-2. Formatting Double and Long Decimal Values -- Problem -- Solution -- How It Works -- 4-3. Comparing int Values -- Problem -- Solution #1 -- Solution #2 -- How It Works -- 4-4. Comparing Floating-Point Numbers -- Problem -- Solution #1 -- Solution #2 -- How It Works -- 4-5. Calculating Monetary Values -- Problem -- Solution -- How It Works -- 4-6. Randomly Generating Values -- Problem -- Solution #1 -- Solution #2 -- How It Works -- 4-7. Obtaining the Current Date Without Time -- Problem -- Solution -- How It Works -- 4-8. Obtaining a Date Object Given Date Criteria -- Problem -- Solution -- How It Works -- 4-9. Obtaining a Year-Month-Day Date Combination -- Problem -- Solution #1 -- Solution #2 -- How It Works -- 4-10. Obtaining and Calculating Based on the Current Time -- Problem -- Solution -- How It Works -- 4-11. Obtaining and Using the Date and Time Together -- Problem -- Solution #1 -- Solution #2 -- Solution #3 -- How It Works -- 4-12. Obtaining a Machine Timestamp -- Problem -- Solution -- How It Works -- 4-13. Converting Dates and Times Based on the Time Zone -- Problem -- Solution -- How It Works -- 4-14. Comparing Two Dates -- Problem -- Solution -- How It Works -- 4-15. Finding the Interval Between Dates and Times -- Problem -- Solution #1 -- Solution #2 -- Solution #3 -- How It Works -- 4-16. Obtaining Date-Time from a Specified String -- Problem -- Solution -- How It Works -- 4-17. Formatting Dates for Display -- Problem -- Solution #1 -- Solution #2 -- How It Works -- 4-18. Writing Readable Numeric Literals -- Problem -- Solution -- How It Works -- 4-19. Declaring Binary Literals -- Problem -- Solution -- How It Works -- Summary -- ch. 5 Object-Oriented Java -- 5-1. Controlling Access to Members of a Class -- Problem -- Solution -- How It Works -- 5-2. Making Private Fields Accessible To Other Classes -- Problem -- Solution -- How It Works -- 5-3. Creating a Class with a Single Instance -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 5-4. Generating Instances of a Class -- Problem -- Solution -- How It Works -- 5-5. Creating Reusable Objects -- Problem -- Solution -- How It Works -- 5-6. Defining an Interface for a Class -- Problem -- Solution -- How It Works -- 5-7. Modifying Interfaces without Breaking Existing Code -- Problem -- Solution -- How It Works -- 5-8. Constructing Instances of the Same Class with Different Values -- Problem -- Solution -- How It Works -- 5-9. Interacting with a Class via Interfaces -- Problem -- Solution -- How It Works -- 5-10. Making a Class Cloneable -- Problem -- Solution -- How It Works -- 5-11. Comparing Objects -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 5-12. Extending the Functionality of a Class -- Problem -- Solution -- How It Works -- 5-13. Defining a Template for Classes to Extend -- Problem -- Solution -- How It Works -- 5-14. Increasing Class Encapsulation -- Problem -- Solution -- How It Works -- Summary -- ch. 6 Lambda Expressions -- 6-1. Writing a Simple Lambda Expression -- Problem -- Solution -- How It Works -- 6-2. Enabling the Use of Lambda Expressions -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 6-3. Sorting with Fewer Lines of Code -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 6-4. Specifying Filter Criteria on a Collection of Data -- Problem -- Solution -- How It Works -- 6-5. Implementing Runnable -- Problem -- Solution -- How It Works -- 6-6. Replacing Anonymous Inner Classes -- Problem -- Solution -- How It Works -- 6-7. Accessing Class Variables from a Lambda Expression -- Problem -- Solution -- How It Works -- 6-8. Passing Lambda Expressions to Methods -- Problem -- Solution -- How It Works -- 6-9. Invoking Existing Methods by Name -- Problem -- Solution -- How It Works -- Summary -- ch
7 Data Structures and Collections -- 7-1. Defining a Fixed Set of Related Constants -- Problem -- Solution -- How It Works -- 7-2. Designing Intelligent Constants -- Problem -- Solution -- How It Works -- 7-3. Executing Code Based on a Specified Value -- Problem -- Solution -- How It Works -- 7-4. Working with Fix-Sized Arrays -- Problem -- Solution -- How It Works -- 7-5. Safely Enabling Types or Methods to Operate on Objects of Various Types -- Problem -- Solution -- How It Works -- 7-6. Working with Dynamic Arrays -- Problem -- Solution -- How It Works -- 7-7. Making Your Objects Iterable -- Problem -- Solution -- How It Works -- 7-8. Iterating Over Collections -- Problem -- Solution -- How It Works -- 7-9. Iterating Over a Map -- Problem -- Solution -- How It Works -- 7-10. Executing Streams in Parallel -- Problem -- Solution -- How It Works -- Summary -- ch. 8 Input and Output -- 8-1. Serializing Java Objects -- Problem -- Solution -- How It Works -- 8-2. Serializing Java Objects More Efficiently -- Problem -- Solution -- How It Works -- 8-3. Serializing Java Objects as XML -- Problem -- Solution -- How It Works -- 8-4. Creating a Socket Connection and Sending Serializable Objects Across the Wire -- Problem -- Solution -- How It Works -- 8-5. Obtaining the Java Execution Path -- Problem -- Solution -- How It Works -- 8-6. Copying a File -- Problem -- Solution -- How It Works -- 8-7. Moving a File -- Problem -- Solution -- How It Works -- 8-8. Creating a Directory -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 8-9. Iterating Over Files in a Directory -- Problem -- Solution -- How It Works -- 8-10. Querying (and Setting) File Metadata -- Problem -- Solution -- How It Works -- 8-11. Monitoring a Directory for Changes -- Problem -- Solution -- How It Works -- 8-12. Reading Property Files -- Problem -- Solution -- How It Works -- 8-13. Uncompressing Compressed Files -- Problem -- Solution -- How It Works -- Summary
Note continued: ch. 9 Exceptions and Logging -- 9-1. Catching Exceptions -- Problem -- Solution -- How It Works -- 9-2. Guaranteeing A Block Of Code is Executed -- Problem -- Solution -- How It Works -- 9-3. Throwing Exceptions -- Problem -- Solution -- How It Works -- 9-4. Catching Multiple Exceptions -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 9-5. Catching the Uncaught Exceptions -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 9-6. Managing Resources with try/catch Blocks -- Problem -- Solution -- How It Works -- 9-7. Creating an Exception Class -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 9-8. Rethrowing the Caught Exception -- Problem -- Solution -- How It Works -- 9-9. Logging Events Within Your Application -- Problem -- Solution -- How It Works -- 9-10. Rotating and Purging Logs -- Problem -- Solution -- How It Works -- 9-11. Logging Exceptions -- Problem -- Solution -- How It Works -- ch. 10 Concurrency -- 10-1. Starting a Background Task -- Problem -- Solution -- How It Works -- 10-2. Updating (and Iterating) a Map -- Problem -- Solution -- How It Works -- 10-3. Inserting a Key into a Map Only if the Key Is not Already Present -- Problem -- Solution -- How It Works -- 10-4. Iterating Through a Changing Collection -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 10-5. Coordinating Different Collections -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 10-6. Splitting Work into Separate Threads -- Problem -- Solution -- How It Works -- 10-7. Coordinating Threads -- Problem -- Solution 1 -- Solution 2 -- Solution 3 -- How It Works -- 10-8. Creating Thread-Safe Objects -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 10-9. Implementing Thread-Safe Counters -- Problem -- Solution -- How It Works -- 10-10. Breaking Down Tasks into Discrete Units of Work -- Problem -- Solution -- How It Works -- 10-11. Updating a Common Value Across Multiple Threads -- Problem -- Solution -- How It Works -- Summary -- ch. 11 Debugging and Unit Testing -- 11-1. Understanding Exceptions -- Problem -- Solution -- How It Works -- 11-2. Locking Down Behavior of Your Classes -- Problem -- Solution -- How It Works -- 11-3. Scripting Your Unit Tests -- Problem -- Solution -- How It Works -- 11-4. Finding Bugs Early -- Problem -- Solution -- How It Works -- 11-5. Monitoring Garbage Collection in your Application -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 11-6. Obtaining a Thread Dump -- Problem -- Solution -- How It Works -- ch. 12 Unicode, Internationalization, and Currency Codes -- 12-1. Converting Unicode Characters to Digits -- Problem -- Solution -- How It Works -- 12-2. Creating and Working with Locales -- Problem -- Solution -- How It Works -- 12-3. Setting the Default Locale -- Problem -- Solution -- How It Works -- 12-4. Matching and Filtering Locales -- Problem -- Solution -- How It Works -- 12-5. Searching Unicode with Regular Expressions -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 12-6. Overriding the Default Currency -- Problem -- Solution -- How It Works -- 12-7. Converting Byte Arrays to and from Strings -- Problem -- Solution -- How It Works -- 12-8. Converting Character Streams and Buffers -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 12-9. Setting the Search Order of Locale-Sensitive Services -- Problem -- Solution -- How It Works -- Summary -- ch. 13 Working with Databases -- 13-1. Connecting to a Database -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 13-2. Handling Connection and SQL Exceptions -- Problem -- Solution -- How It Works -- 13-3. Querying a Database and Retrieving Results -- Problem -- Solution -- How It Works -- 13-4. Performing CRUD Operations -- Problem -- Solution -- How It Works -- 13-5. Simplifying Connection Management -- Problem -- Solution -- How It Works -- 13-6. Guarding Against SQL Injection -- Problem -- Solution -- How It Works -- 13-7. Performing Transactions -- Problem -- Solution -- How It Works -- 13-8. Creating a Scrollable ResultSet -- Problem -- Solution -- How It Works -- 13-9. Creating an Updatable ResultSet -- Problem -- Solution -- How It Works -- 13-10. Caching Data for Use When Disconnected -- Problem -- Solution -- How It Works -- 13-11. Joining RowSet Objects When Not Connected to the Data Source -- Problem -- Solution -- How It Works -- 13-12. Filtering Data in a RowSet -- Problem -- Solution -- How It Works -- 13-13. Querying and Storing Large Objects -- Problem -- Solution -- How It Works -- 13-14. Invoking Stored Procedures -- Problem -- Solution -- How It Works -- 13-15. Obtaining Dates for Database Use -- Problem -- Solution -- How It Works -- 13-16. Handling Resources Automatically -- Problem -- Solution -- How It Works -- Summary -- ch. 14 JavaFX Fundamentals -- 14-1. Creating a Simple User Interface -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 14-2. Drawing Text -- Problem -- Solution -- How It Works -- 14-3. Changing Text Fonts -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 14-4. Creating Shapes -- Problem -- Solution -- How It Works -- 14-5. Assigning Colors to Objects -- Problem -- Solution -- How It Works -- 14-6. Creating Menus -- Problem -- Solution -- How It Works -- 14-7. Adding Components to a Layout -- Problem -- Solution -- How It Works -- 14-8. Generating Borders -- Problem -- Solution -- How It Works -- 14-9. Binding Expressions -- Problem -- Solution -- How It Works -- 14-10. Creating and Working with Observable Lists -- Problem -- Solution -- How It Works -- 14-11. Generating a Background Process -- Problem -- Solution -- How It Works -- 14-12. Associating Keyboard Sequences with Applications -- Problem -- Solution -- How It Works -- 14-13. Creating and Working with Tables -- Problem -- Solution -- How It Works -- 14-14. Organizing the Ul with Split Views -- Problem -- Solution -- How It Works -- 14-15. Adding Tabs to the Ul -- Problem -- Solution -- How It Works -- 14-16. Developing a Dialog Box -- Problem -- Solution -- How It Works -- 14-17. Printing with JavaFX -- Problem -- Solution -- How It Works -- 14-18. Embedding Swing Content in JavaFX -- Problem -- Solution -- How It Works -- Summary -- ch. 15 Graphics with JavaFX -- 15-1. Creating Images -- Problem -- Solution -- How It Works -- 15-2. Generating an Animation -- Problem -- Solution -- How It Works -- 15-3. Animating Shapes Along a Path -- Problem -- Solution -- How It Works -- 15-4. Manipulating Layout via Grids -- Problem -- Solution -- How It Works -- 15-5. Enhancing the Interface with CSS -- Problem -- Solution -- How It Works -- Summary -- ch. 16 Media with JavaFX -- 16-1. Playing Audio -- Problem -- Solution -- How It Works -- 16-2. Playing Video -- Problem -- Solution -- How It Works -- 16-3. Controlling Media Actions and Events -- Problem -- Solution -- How It Works -- 16-4. Marking a Position in a Video -- Problem -- Solution -- How It Works -- 16-5. Synchronizing Animation and Media -- Problem -- Solution -- How It Works -- Summary -- ch
17 JavaFX on the Web -- 17-1. Embedding JavaFX Applications in a Web Page -- Problem -- Solution -- How It Works -- 17-2. Loading Scalable Vector Graphics File Content -- Problem -- Solution -- How It Works -- 17-3. Manipulating HTML5 Content with Java Code -- Problem -- Solution -- How It Works -- 17-4. Responding to HTML Events -- Problem -- Solution -- How It Works -- 17-5. Displaying Content from the Database -- Problem -- Solution -- How It Works -- Summary -- ch. 18 Nashorn and Scripting -- 18-1. Loading and Executing JavaScript from Java -- Problem -- Solution -- How It Works -- 18-2. Executing JavaScript via the Command Line -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 18-3. Embedding Expressions in Strings -- Problem -- Solution -- How It Works -- 18-4. Passing Java Parameters -- Problem -- Solution -- How It Works -- 18-5. Passing Return Values from JavaScript to Java -- Problem -- Solution -- How It Works -- 18-6. Using Java Classes and Libraries -- Problem -- Solution -- How It Works -- 18-7. Accessing Java Arrays and Collections in Nashorn -- Problem -- Solution -- How It Works -- 18-8. Implementing Java Interfaces -- Problem -- Solution -- How It Works -- 18-9. Extending Java Classes -- Problem -- Solution -- How It Works -- 18-10. Creating Executable Scripts in Unix -- Problem -- Solution -- How It Works -- 18-11. Implementing JavaFX with Nashorn -- Problem -- Solution 1 -- Solution 2 -- How It Works -- Summary -- ch. 19 E-mail -- 19-1. Installing JavaMail -- Problem -- Solution -- How It Works -- 19-2. Sending an E-mail -- Problem -- Solution -- How It Works -- 19-3. Attaching Files to an E-Mail Message -- Problem -- Solution -- How It Works -- 19-4. Sending an HTML E-Mail -- Problem -- Solution -- How It Works -- 19-5. Sending E-Mail to a Group of Recipients -- Problem -- Solution -- How It Works -- 19-6. Checking E-Mail -- Problem -- Solution -- How It Works
Note continued: 19-7. Monitoring an E-Mail Account -- Problem -- Solution -- How It Works -- Summary -- ch. 20 XML Processing -- 20-1. Writing an XML File -- Problem -- Solution -- How It Works -- 20-2. Reading an XML File -- Problem -- Solution 1 -- Solution 2 -- How It Works -- 20-3. Transforming XML -- Problem -- Solution -- How It Works -- 20-4. Validating XML -- Problem -- Solution -- How It Works -- 20-5. Creating Java Bindings for an XML Schema -- Problem -- Solution -- How It Works -- 20-6. Unmarshalling XML to a Java Object -- Problem -- Solution -- How It Works -- 20-7. Building an XML Document with JAXB -- Problem -- Solution -- How It Works -- Summary -- ch. 21 Networking -- 21-1. Listening for Connections on the Server -- Problem -- Solution -- How It Works -- 21-2. Defining a Network Connection to a Server -- Problem -- Solution -- How It Works -- 21-3. Bypassing TCP for InfiniBand to Gain Performance Boosts -- Problem -- Solution -- How It Works -- 21-4. Broadcasting to a Group of Recipients -- Problem -- Solution -- How It Works -- 21-5. Generating and Reading from URLs -- Problem -- Solution -- How It Works -- 21-6. Parsing a URL -- Problem -- Solution -- How It Works -- Summary -- ch. 22 Security -- 22-1. Asserting a Subset of Privileges -- Problem -- Solution -- How It Works -- 22-2. Indicating a Server Name for Handshaking -- Problem -- Solution -- How It Works -- 22-3. Specifying a Keystore Password -- Problem -- Solution -- How It Works -- 22-4. Generating the Strongest Random Number Possible -- Problem -- Solution -- How It Works -- 22-5. Granting Permissions for Rich Internet Applications -- Problem -- Solution -- How It Works -- Summary
Summary Java 8 Recipes offers solutions to common programming problems encountered while developing Java-based applications. Fully updated with the newest features and techniques available, Java 8 Recipes provides code examples involving Lambdas, embedded scripting with Nashorn, the new date-time API, stream support, functional interfaces, and much more. Especial emphasis is given to features such as lambdas that are newly introduced in Java 8. Content is presented in the popular problem-solution format: Look up the programming problem that you want to solve. Read the solution. Apply the solution directly in your own code. Problem solved! The problem-solution approach sets Java 8 Recipes apart. Java 8 Recipes is focused less on the language itself and more on what you can do with it that is useful. The book respects your time by always focusing on a task that you might want to perform using the language. Solutions come first. Explanations come later. You are free to crib from the book and apply the code examples directly to your own projects. Covers the newly-released Java 8, including a brand new chapter on lambdas Focuses especially on up-and-coming technologies such as Project Nashorn and Java FX 2.0 Respects your time by focusing on practical solutions you can implement in your own code
Notes Includes index
Online resource; title from PDF title page (EBSCO, viewed November 28, 2017)
Subject Java (Computer program language)
Form Electronic book
ISBN 9781430268260 (electronic bk.)
1430268263 (electronic bk.)