You are previewing Java™ Phrasebook.
O'Reilly logo
Java™ Phrasebook

Book Description

Essential Code and Commands

Java Phrasebook gives you the code phrases you need to quickly and effectively complete your programming projects in Java.

Concise and Accessible

Easy to carry and easy to use—lets you ditch all those bulky books for one portable guide

Flexible and Functional

Packed with more than 100 customizable code snippets—so you can readily code functional Java in just about any situation

Timothy Fisher has been working professionally in the Java software development field since 1997 and is currently a consultant for the Compuware Corporation in Detroit, Michigan. He enjoys writing about technology and has been a contributor to Java Developer’s Journal and XML Journal. Tim is also passionate about education and the use of advanced Internet technologies for education.

Programming / Java

Table of Contents

  1. Copyright
    1. Dedication
  2. About the Author
  3. Acknowledgments
  4. We Want to Hear from You!
    1. Reader Services
  5. Introduction
  6. The Basics
    1. Compiling a Java Program
    2. Running a Java Program
    3. Setting the Classpath
  7. Interacting with the Environment
    1. Getting Environment Variables
    2. Setting and Getting System Properties
    3. Parsing Command-Line Arguments
  8. Manipulating Strings
    1. Comparing Strings
    2. Searching For and Retrieving Substrings
    3. Processing a String One Character at a Time
    4. Reversing a String by Character
    5. Reversing a String by Word
    6. Making a String All Uppercase or All Lowercase
    7. Trimming Spaces from the Beginning or End of a String
    8. Parsing a Comma-Separated String
  9. Working with Data Structures
    1. Resizing an Array
    2. Iterating Over a Collection
    3. Creating a Mapped Collection
    4. Sorting a Collection
    5. Finding an Object in a Collection
    6. Converting a Collection to an Array
  10. Dates and Times
    1. Finding Today’s Date
    2. Converting Between Date and Calendar Objects
    3. Printing Date/Time in a Given Format
    4. Parsing Strings into Dates
    5. Adding to or Subtracting from a Date or Calendar
    6. Calculating the Difference Between Two Dates
    7. Comparing Dates
    8. Finding the Day of Week/Month/Year or Week Number
    9. Calculating Elapsed Time
  11. Pattern Matching with Regular Expressions
    1. Regular Expressions in Java
    2. Finding Matching Text Using a Regular Expression
    3. Replacing Matched Text
    4. Finding All Occurrences of a Pattern
    5. Printing Lines Containing a Pattern
    6. Matching Newlines in Text
  12. Numbers
    1. Checking Whether a String Is a Valid Number
    2. Comparing Floating Point Numbers
    3. Rounding Floating Point Numbers
    4. Formatting Numbers
    5. Formatting Currencies
    6. Converting an Integer to Binary, Octal, and Hexadecimal
    7. Generating Random Numbers
    8. Calculating Trigonometric Functions
    9. Calculating a Logarithm
  13. Input and Output
    1. Reading Text from Standard Input
    2. Writing to Standard Output
    3. Formatting Output
    4. Opening a File by Name
    5. Reading a File into a Byte Array
    6. Reading Binary Data
    7. Seeking in a File
    8. Reading a JAR or Zip Archive
    9. Creating a Zip Archive
  14. Working with Directories and Files
    1. Creating a File
    2. Renaming a File or Directory
    3. Deleting a File or Directory
    4. Changing File Attributes
    5. Getting the Size of a File
    6. Determining if a File or Directory Exists
    7. Moving a File or Directory
    8. Getting an Absolute Filename Path from a Relative Filename Path
    9. Determining if a Filename Path is a File or Directory
    10. Listing a Directory
    11. Creating a New Directory
  15. Network Clients
    1. Contacting a Server
    2. Finding IP Addresses and Domain Names
    3. Handling Network Errors
    4. Reading Text
    5. Writing Text
    6. Reading Binary Data
    7. Writing Binary Data
    8. Reading Serialized Data
    9. Writing Serialized Data
    10. Reading a Web Page via HTTP
  16. Network Servers
    1. Creating a Server and Accepting a Request
    2. Returning a Response
    3. Returning an Object
    4. Handling Multiple Clients
    5. Serving HTTP Content
  17. Sending and Receiving Email
    1. Overview of JavaMail API
    2. Sending Email
    3. Sending MIME Email
    4. Reading Email
  18. Database Access
    1. Connecting to a Database via JDBC
    2. Sending a Query via JDBC
    3. Using a Prepared Statement
    4. Retrieving Results of a Query
    5. Using a Stored Procedure
  19. Using XML
    1. Parsing XML with SAX
    2. Parsing XML with DOM
    3. Using a DTD to Verify an XML Document
    4. Creating an XML Document with DOM
    5. Transforming XML with XSLT
  20. Using Threads
    1. Starting a Thread
    2. Stopping a Thread
    3. Waiting For a Thread to Complete
    4. Synchronizing Threads
    5. Pausing a Thread
    6. Listing All Threads
  21. Dynamic Programming Through Reflection
    1. Getting a Class Object
    2. Getting a Class Name
    3. Discovering Class Modifiers
    4. Finding Superclasses
    5. Determining the Interfaces Implemented by a Class
    6. Discovering Class Fields
    7. Discovering Class Constructors
    8. Discovering Method Information
    9. Getting Field Values
    10. Setting Field Values
    11. Invoking Methods
    12. Loading and Instantiating a Class Dynamically
  22. Packaging and Documenting Classes
    1. Creating a Package
    2. Documenting Classes with JavaDoc
    3. Archiving Classes with Jar
    4. Running a Program from a JAR File
  23. Index