O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Wicked Cool Java

Book Description

Wicked Cool Java contains 101 fun, interesting, and useful ways to get more out of Java. This isn't intended as a Java tutorial--it's targeted at developers and system architects who have some basic Java knowledge but may not be familiar with the wide range of libraries available. Full of example code and ideas for combining them in useful projects, this book is perfect for hobbyists, and professionals will find tips and open-source projects to enhance their code and make their jobs easier. Topics include converting a non-XML text structure into XML using a parser generator, experimenting with a Java simulator for the Cell Matrix, creating dynamic music and sound in Java, working with open-source class libraries for scientific and mathematical applications, and many more.

Table of Contents

  1. Copyright
  2. Dedication
  3. Acknowledgments
  4. Introduction
    1. Organization of This Book
    2. The Website
  5. Java Language and Core API
    1. There Is No for In Java: Using the for Loop Enhancements
    2. Let Me Count the Ways: Using the enum
    3. Practice Safe Putting: Using Typesafe Maps
    4. Generally Generic: Writing Methods with Generic Parameters
    5. Arguments and More Arguments: Writing Vararg Methods
    6. Being Assertive: Using Java Assertions
    7. Living on Nano Time: Using System.nanoTime
    8. Taking a Very Short Nap: Sub-Millisecond Sleep for Threads
    9. You Shall Remain Nameless: Creating an Anonymous Class
    10. Equals Rights: == != .equals
    11. Chapter Summary
  6. String Utilities
    1. Staying Regular: Using Regular Expressions to Search Text
    2. Splitsville: Using the String.split Method
    3. Smartly Subbing: Finding Substring Patterns Within a String
    4. Getting Captured: Using Regex Capturing Groups
    5. A String of Substitutes: Substituting with Regular Expressions
    6. Partially Parseable: Parsing with the Scanner Class
    7. Scan-Do Attitude: Parsing Complex Syntax with the Scanner Class
    8. Making It All Up: Generating Random Text
    9. Array of Hope: Displaying Arrays in Java 1.5
    10. No Bits Allowed: Encoding and Decoding Binary Data
    11. A Message for Matt: Formatting Strings with MessageFormat
    12. The Reincarnation of printf: Formatting Strings with Formatter
    13. Chapter Summary
  7. Processing XML and HTML
    1. Quick XML Refresher
    2. Stop and XML the Rowsets: Using WebRowSet to Create XML
    3. Stacks of SAX: Remembering Tag Relationships in SAX
    4. Playing the SAX: Directly Feeding a ContentHandler
    5. Mustard on a SAX-wich: Filter-Feeding a ContentHandler
    6. Easy Reading: Using DOM4J to Read XML Documents
    7. Eck's Path: Using XPath for Easy Data Extraction
    8. Invisible Tags: Filtering Documents Before Loading into DOM4J
    9. Sin Taxes: Generating Parsers for Anything with JavaCC
    10. To XML and Beyond: Converting Other Grammars into XML
    11. Scraping the Sun: Screen Scraping HTML Pages for Data
    12. What's Lou Seen? Searching with Lucene
    13. Chapter Summary
  8. Crawling the Semantic Web
    1. This Somethings That: A Short Introduction to N3 and Jena
    2. Triple the Fun: Creating an RDF Vocabulary for Your Organization
    3. Who's a What? Using RDF Hierarchies in Jena
    4. Getting Attached: Attaching Dublin Core to HTML Documents
    5. What's the Reason? Making Queries with Jena RDQL
    6. Simply Logical: Lojban, RDF, and the Jorne Project
    7. Guess What? Publishing RSS Newsfeeds with Informa
    8. What's Up? Aggregating RSS Newsfeeds
    9. Heading to the Polls: Polling RSS Feeds with Informa
    10. All the News Fit to Print: Filtering RSS Feeds with Informa
    11. Chapter Summary
  9. Scientific and Mathematical Applications
    1. Fun-Tors: Creating and Applying Functors
    2. Funkier Functors: Using Composite Functors
    3. High-Caliber Bits: Using Colt's BitVector
    4. The Truth Is in There: Creating Truth Tables from a BitMatrix
    5. Two Terafurlongs per Fortnight: Using JScience Quantities
    6. Fractious Fractions: Arbitrary-Precision Arithmetic
    7. Proudly Polynomial: Using Algebraic Functions in JScience
    8. Connecting the Nots: Connecting Truth Tables Using Ports
    9. The Knee Bone's Connected to the...: Connecting with JGraphT
    10. Tied Up in Meta-Nots: Connecting Generic Processing Units
    11. Joone Bugs: Building Neural Networks in Joone
    12. It's Alive! Using JGAP for Genetic Algorithms
    13. IA Is AI: Building Intelligent Agents Using Jade
    14. Word Up: Navigating English with JWordNet
    15. Chapter Summary
  10. Graphics and Data Visualization
    1. Gooey XML: Defining Java GUIs in XML
    2. To the Vector Goes the Spoils: Visualizing Data with SVG
    3. See SVG: Viewing SVG Content with Batik
    4. Body Art: Converting JGraphT into a JGraph View
    5. Attri-Beauty: Using JGraph Attribute Maps
    6. Charting New Territory: Creating Charts with JFreeChart
    7. Reporting for Duty: Creating Reports in Java
    8. Periodic Patterns: Simple 2D Data Visualization
    9. A Fine Transform: Using Affine Transformations in Java 2D
    10. Room to Zoom: Building Zoomable GUIs with Piccolo
    11. Chapter Summary
  11. Multimedia and Synchronization
    1. Fugue Fun: Making Music with JFugue
    2. Fugue in Mid-D: Using JFugue with Java Sound MIDI
    3. All MIDI-ed Out: Sending Events to a MIDI Output Device
    4. Beeps and Bleeps: Synthesizing Sounds with JMusic
    5. Hiss, Buzz, Hum: Using Noise and Complex Synthesis in JMusic
    6. Getting an Outside Line: Working with Low-Level Java Sound
    7. Yes, Dear, I'm Listening: Reading Audio from an Input Line
    8. Talk to Me! Using Java Speech to Make Programs Talk
    9. Reduce, Reuse, Recycle: GC and the Javolution Real-Time APIs
    10. Hurry Up and Wait: Synchronizing Threads Using CyclicBarrier
    11. Chapter Summary
  12. Fun, Integration, and Project Ideas
    1. Think Outside the Blocks: Using Java to Control a LEGO Robot
    2. Aye, Robot: Controlling the Mouse with the AWT Robot Class
    3. Click and Pick: Picking Dates Using JCalendar
    4. Post Haste: Using HttpClient to Post Forms to HTTP Servers
    5. She Sells C Cells: Simulating a Cell Matrix in Java
    6. Nature's May Tricks: Evolving Cell Matrices
    7. A Real Worker Ant: Running Applications with Apache Ant
    8. Playing a Shell Game: Using BeanShell
    9. Testing, Testing, Testing: Creating JUnit Tests
    10. Peering into the Future: Using JXTA for Peer-to-Peer Applications
    11. Grid Is Good: Using the Globus Toolkit and Grid Computing
    12. Jabberwocky: Adding Chat to Your Application with Jabber
    13. Some Assembly Required: Writing JVM Assembly Language
    14. Bytecode Critters: Combining Genetic Programming with BCEL
    15. Coffee Substitutes: Compiling Other Languages to Bytecode
    16. LojViz: Grammar Visualizer for Lojban
    17. Pitch Patch: Synthesizer Patch Editor
    18. Words with Wires: WordNet Explorer
    19. News on Tap: Automated Newsfeed Generator
    20. Robot School: Neural Net Robotics
    21. Annotation Innovation: Java 5.0 Annotation Management Tool
    22. The Winds of Change: Using CVS and Source Code Control
    23. Forging Ahead: Using SourceForge for Your Projects
    24. Chapter Summary
  13. Glossary
  14. Updates
  15. Index