-->
Navigation
Java® All-in-One For Dummies®, 5th Edition

Java® All-in-One For Dummies®, 5th Edition

Now pay Easier and Secure using Paypal
Price:

Read more

8 BOOKS IN ONE

by Doug Lowe

at a Glance

Book 1: Java Basics
Welcome to Java
Installing and Using Java Tools
Working with TextPad
Book 2: Programming Basics
Java Programming Basics
Working with Variables and Data Types
Working with Numbers and Expressions
Making Choices
Going Around in Circles (Or, Using Loops)
Pulling a Switcheroo
Adding Some Methods to Your Madness
Handling Exceptions
Book 3: Object-Oriented Programming
Understanding Object-Oriented Programming
Making Your Own Classes
Working with Statics
Using Subclasses and Inheritance
Using Abstract Classes and Interfaces
Using the Object and Class Classes
Using Inner Classes, Anonymous Classes,
and Lambda Expressions
Working with Packages and the New Java Module System
Book 4: Strings, Arrays, and Collections
Working with Strings
Using Arrays
Using the ArrayList Class
Using the LinkedList Class
Creating Generic Collection Classes
Using Bulk Data Operations with Collections
Book 5: Programming Techniques
Programming Threads
Using Regular Expressions
Using Recursion
Working with Dates and Times
Book 6: JavaFX
Hello, JavaFX!
Handling Events
Setting the Stage and Scene Layout
Using Layout Panes to Arrange Your Scenes
Getting Input from the User
Choosing from a List
Book 7: Web Programming
Using Java Web Start
Creating Servlets
Using JavaServer Pages
Using JavaBeans
Book 8: Files and Databases
Working with Files
Working with File Streams
Database for $100, Please
Using JDBC to Connect to a Database
Working with XML

e-books shop
e-books shop
Purchase Now !
Just with Paypal



Book Details
 Price
 4.00 USD
 Pages
 963 p
 File Size
 14,870 KB
 File Type
 PDF format
 ISBN
 978-1-119-24779-1 (pbk)
 978-1-119-24780-7 (ebk)
 978-1-119-24781-4 (ebk)
 Copyright   
 2017 by John Wiley & Sons, Inc 

About This Book
Java All-in-One For Dummies, 5th Edition, is a reference for all the great things (and
maybe a few not-so-great things) that you may need to know when you’re writing
Java programs. You can, of course, buy a huge 1,200-page book on each of the
programming topics covered in this book. But then, who would carry them home
from the bookstore for you? And where would you find the shelf space to store
them? And when will you find the time to read them?

In this book, all the information you need is conveniently packaged for you inbetween
one set of covers. And all of the information is current for the newest
release of Java, known as JDK 9. This book doesn’t pretend to be a comprehensive
reference for every detail on every possible topic related to Java programming.
Instead, it shows you how to get up and running fast so that you have more time
to do the things you really want to do. Designed using the easy-to-follow For
Dummies format, this book helps you get the information you need without laboring to find it.

Java All-in-One For Dummies, 5th Edition, is a big book made up of nine smaller
books — minibooks, if you will. Each of these minibooks covers the basics of
one key element of programming, such as installing Java and compiling and
running programs, or using basic Java statements, or using JavaFX to write GUI applications.

Whenever one big thing is made up of several smaller things, confusion is always
a possibility. That’s why this book has multiple access points. At the beginning
is a detailed table of contents that covers the entire book. Then each minibook
begins with a minitable of contents that shows you at a miniglance what chapters
are included in that minibook. Useful running heads appear at the top of each page
to point out the topic discussed on that page. And handy thumbtabs run down the
side of the pages to help you find each minibook quickly. Finally, a comprehensive
index lets you find information anywhere in the entire book.

Introduction
Welcome to Java All-in-One For Dummies, 5th Edition — the one Java book
that’s designed to replace an entire shelf full of the dull, tedious titles
you’d otherwise have to buy. This book contains all the basic information
you need to know to get going with Java programming, starting with writing
statements and using variables and ending with techniques for writing programs
that use animation and play games. Along the way, you find plenty of not-sobasic
information about programming user interfaces, working with classes and
objects, creating web applications, and dealing with files and databases.

You can (and probably should, eventually) buy separate books on each of these
topics. It won’t take long before your bookshelf is bulging with 10,000 or more
pages of detailed information about every imaginable nuance of Java programming.
But before you’re ready to tackle each of those topics in depth, you need to
get a bird’s-eye picture. That’s what this book is about.

And if you already own 10,000 pages or more of Java information, you may be
overwhelmed by the amount of detail and wonder, “Do I really need to read
1,200 pages about JSP just to create a simple web page? And do I really need a
six-pound book on JavaFX?” Truth is, most 1,200-page programming books have
about 200 pages of really useful information — the kind you use every day —
and about 1,000 pages of excruciating details that apply mostly if you’re writing
guidance-control programs for nuclear missiles or trading systems for the
New York Stock Exchange.

The basic idea here is that I’ve tried to wring out the 100-or-so most useful
pages of information on these different Java programming topics: setup and
configuration, basic programming, object-oriented programming, programming
techniques, JavaFX, file and database programming, web programming, and animation
and game programming. Thus you get a nice, trim book.

So whether you’re just getting started with Java programming or you’re a seasoned
pro, you’ve found the right book.

Table of Contents
INTRODUCTION. 1
About This Book. 2
Foolish Assumptions. 2
Icons Used in This Book. 3
Beyond the Book. 4
Where to Go from Here. 4
BOOK 1: JAVA BASICS. 5
CHAPTER 1: Welcome to Java. 7
What Is Java, and Why Is It So Great?. 8
Platform independence. 8
Object orientation. 9
The Java API . 10
The Internet. 11
Java versus Other Languages. .12
Important Features of the Java Language. 13
Type checking. 13
Automatic memory management. 15
Exception handling. 16
On the Downside: Java’s Weaknesses . 16
Java Version Insanity. 17
What’s in a Name?. 19
CHAPTER 2: Installing and Using Java Tools. 21
Downloading and Installing the Java Development Kit. 22
Downloading the JDK . 22
Installing the JDK. 23
Perusing the JDK folders. 23
Setting the path. 24
Using Java’s Command-Line Tools . 26
Compiling a program . 26
Compiling more than one file . 27
Using Java compiler options. 28
Running a Java program. 29
Using the javap command. 31
Using Java Documentation. 32
Java SE API Docs. 32
Java Language Specification. 33
CHAPTER 3: Working with TextPad. 35
Downloading and Installing TextPad . 35
Editing Source Files. 36
Compiling a Program . 39
Running a Java Program. 40
BOOK 2: PROGRAMMING BASICS. 43
CHAPTER 1: Java Programming Basics. 45
Looking at the Infamous Hello, World! Program . 46
Dealing with Keywords. 49
Working with Statements. 51
Types of statements. 51
White space . 52
Working with Blocks. 53
Creating Identifiers. 55
Crafting Comments. 55
End-of-line comments. 56
Traditional comments. 56
JavaDoc comments. 57
Introducing Object-Oriented Programming . 57
Understanding classes and objects . 57
Understanding static methods . 58
Creating an object from a class. 59
Viewing a program that uses an object. 60
So what’s the difference?. 62
Importing Java API Classes. 63
CHAPTER 2: Working with Variables and Data Types. 65
Declaring Variables. 66
Declaring two or more variables in one statement. 67
Declaring class variables . 67
Declaring instance variables . 68
Declaring local variables. 69
Initializing Variables . 70
Initializing variables with assignment statements. 71
Initializing variables with initializers. 72
Using Final Variables (Constants) . 72
Working with Primitive Data Types. 73
Integer types . 75
Floating-point types  .76
The char type. 78
The Boolean type. 79
Wrapper classes. 79
Using Reference Types. 80
Working with Strings. 82
Declaring and initializing strings. 82
Combining strings. 83
Converting primitives to strings . 83
Converting strings to primitives . 84
Converting and Casting Numeric Data. 85
Automatic conversions. 85
Type casting. 86
Thinking Inside the Box . 87
Understanding Scope. 87
Shadowing Variables. 89
Printing Data with System.out. 90
Using standard input and output streams . 90
Using System.out and System.err. 92
Getting Input with the Scanner Class. 92
Importing the Scanner class . 93
Declaring and creating a Scanner object. 94
Getting input . 94
Getting Input with the JOptionPane Class. 96
Using enum to Create Your Own Data Types. 97
CHAPTER 3: Working with Numbers and Expressions  99
Working with Arithmetic Operators. 99
Dividing Integers. 102
Combining Operators. 104
Using the Unary Plus and Minus Operators . 105
Using Increment and Decrement Operators. 106
Using the Assignment Operator. 108
Using Compound Assignment Operators. 110
Using the Math Class . 111
Using constants of the Math class . 112
Working with mathematical functions. 113
Creating random numbers.  .116
Rounding functions. 119
Formatting Numbers . 121
Recognizing Weird Things about Java Math.  124
Integer overflow. 125
Floating-point weirdness . 125
Division by zero. 126
CHAPTER 4: Making Choices. 129
Using Simple Boolean Expressions. 130
Using if Statements. 132
Simple if statements. 132
if-else statements . 134
Nested if statements. 135
else-if statements . 139
Using Mr. Spock’s Favorite Operators (Logical Ones, of Course). 141
Using the ! operator . 142
Using the & and && operators . 143
Using the | and || operators . 144
Using the ^ operator. 145
Combining logical operators. 146
Using the Conditional Operator . 148
Comparing Strings. 149
CHAPTER 5: Going Around in Circles (Or, Using Loops). 151
Using Your Basic while Loop. 152
The while statement. 152
A counting loop. 152
Breaking Out of a Loop. 154
Looping Forever. 154
Letting the user decide when to quit. 156
Letting the user decide in another way. 157
Using the continue Statement. 157
Running do-while Loops. 159
Validating Input from the User. 161
Using the Famous for Loop. 163
Understanding the formal format of the for loop . 164
Scoping out the counter variable . 166
Counting even numbers. 167
Counting backward. 168
Using for loops without bodies. 169
Ganging up your expressions . 170
Omitting expressions. 171
Breaking and continuing your for loops .172
Nesting Your Loops. 173
A simple nested for loop . 173
A guessing game. 174
CHAPTER 6: Pulling a Switcheroo. 179
Battling else-if Monstrosities. 179
Viewing an example else-if program . 180
Creating a better version of the example program. 181
Using the switch Statement. 183
Viewing a boring switch example, complete with flowchart. 184
Putting if statements inside switch statements . 185
Creating Character Cases. 186
Intentionally Leaving Out a Break Statement. 188
Switching with Strings. 191
CHAPTER 7: Adding Some Methods to Your Madness. 193
The Joy of Methods. 194
The Basics of Making Methods. 195
An example. 196
Another example. 197
Methods That Return Values. 199
Declaring the method’s return type. 199
Using the return statement to return the value. 200
Using a method that returns a type. 201
You gotta have a proper return statement. 201
Trying another version of the guessing-game program . 203
Methods That Take Parameters . 206
Declaring parameters. 207
Scoping out parameters. 208
Understanding pass-by-value . 209
Trying yet another version of the guessing-game program. 210
CHAPTER 8: Handling Exceptions. 213
Understanding Exceptions. 214
Witnessing an exception. 215
Finding the culprit. 215
Catching Exceptions . 216
A simple example . 217
Another example. 218
Handling Exceptions with a Preemptive Strike. 220
Catching All Exceptions at Once . 221
Displaying the Exception Message. 223
Using a finally Block . 223
Handling Checked Exceptions. 226
Viewing the catch-or-throw compiler error. 226
Catching FileNotFoundException . 227
Throwing the FileNotFoundException . 228
Throwing an exception from main. 229
Swallowing exceptions. 229
Throwing Your Own Exceptions . 231
Catching Multiple Exceptions. 232
BOOK 3: OBJECT-ORIENTED PROGRAMMING. 233
CHAPTER 1: Understanding Object-Oriented
Programming. 235
What Is Object-Oriented Programming?. 235
Understanding Objects. 237
Objects have identity . 237
Objects have type . 238
Objects have state. 239
Objects have behavior . 240
Understanding the Life Cycle of an Object . 240
Working with Related Classes. 241
Inheritance. 242
Interfaces . 242
Designing a Program with Objects. 243
Diagramming Classes with UML. 244
Drawing classes. 245
Drawing arrows. 246
CHAPTER 2: Making Your Own Classes. 249
Declaring a Class. 249
Picking class names. 250
Knowing what goes in the class body. 250
Seeing where classes go. 251
Working with Members . 253
Understanding fields. 253
Understanding methods . 254
Understanding visibility . 254
Using Getters and Setters . 255
Overloading Methods. 257
Creating Constructors. 259
Creating basic constructors. 259
Creating default constructors. 260
Calling other constructors. 262
Finding More Uses for the this Keyword. 263
Using Initializers. 265
CHAPTER 3: Working with Statics. 267
Understanding Static Fields and Methods. 267
Working with Static Fields . 269
Using Static Methods . 269
Counting Instances. 270
Preventing Instances. 273
Using Static Initializers. 274
CHAPTER 4: Using Subclasses and Inheritance. 277
Introducing Inheritance. 277
Motorcycles, trains, and automobiles . 279
Game play. 279
A businesslike example . 280
Inheritance hierarchies. 280
Creating Subclasses . 281
Overriding Methods . 283
Protecting Your Members . 284
Using this and super in Your Subclasses. 284
Understanding Inheritance and Constructors . 286
Using final. 287
Final methods . 287
Final classes. 288
Casting Up and Down. 289
Determining an Object’s Type. 290
Poly What? . 292
Creating Custom Exceptions. 294
Tracing the Throwable hierarchy . 294
Creating an exception class. 296
Throwing a custom exception. 296
CHAPTER 5: Using Abstract Classes and Interfaces. 299
Using Abstract Classes. 299
Using Interfaces. 302
Creating a basic interface. 303
Implementing an interface. 304
Using an interface as a type. 305
More Things You Can Do with Interfaces. 306
Adding fields to an interface. 306
Extending interfaces. 306
Using interfaces for callbacks . 307
Using Default Methods. 311
CHAPTER 6: Using the Object and Class Classes. 315
The Mother of All Classes: Object. 316
Every object is an Object . 316
Object as a type. 316
Methods of the Object class . .317
Primitives aren’t objects. 319
The toString Method. 319
Using toString. 320
Overriding toString. 321
The equals Method. 322
Using equals. 323
Overriding the equals method . 324
The clone Method. 328
Implementing the clone method. 329
Using clone to create a shallow copy. 332
Creating deep copies . 333
The Class Class. 338
CHAPTER 7: Using Inner Classes, Anonymous
Classes, and Lambda Expressions. 341
Declaring Inner Classes . 342
Understanding inner classes. 342
Viewing an example . 343
Using Static Inner Classes . 345
Using Anonymous Inner Classes. 347
Creating an anonymous class. 347
Creating a program with an anonymous class. 349
Using Lambda Expressions . 351
CHAPTER 8: Working with Packages and the New Java
Module System. 353
Working with Packages. 354
Importing classes and packages. 354
Creating your own packages. 355
An example. 357
Putting Your Classes in a JAR File . 358
jar command-line options . 359
Archiving a package. 360
Adding a jar to your classpath. 361
Running a program directly from an archive . 362
Using JavaDoc to Document Your Classes. 363
Adding JavaDoc comments . 363
Using the javadoc command. 366
Viewing JavaDoc pages. 367
Using the Java Module System . 368
Understanding modules. 369
The module-info.java file. 369
Setting up folders for a module . 371
Compiling a module . 371
Creating a modular JAR file . 372
BOOK 4: STRINGS, ARRAYS, AND COLLECTIONS. 373
CHAPTER 1: Working with Strings. 375
Reviewing Strings .376
Using the String Class. 378
Finding the length of a string. 380
Making simple string modifications. 380
Extracting characters from a string. 381
Extracting substrings from a string. 382
Splitting a string. 384
Replacing parts of a string. 386
Using the StringBuilder and StringBuffer Classes . 387
Creating a StringBuilder object. 388
Using StringBuilder methods. 388
Viewing a StringBuilder example .390
Using the CharSequence Interface. 391
CHAPTER 2: Using Arrays. 393
Understanding Arrays. 393
Creating Arrays . 394
Initializing an Array. 395
Using for Loops with Arrays. 396
Solving Homework Problems with Arrays. 397
Using the Enhanced for Loop . 400
Using Arrays with Methods . 401
Using Two-Dimensional Arrays. 401
Creating a two-dimensional array. 402
Accessing two-dimensional array elements . 403
Initializing a two-dimensional array. 405
Using jagged arrays. 405
Going beyond two dimensions. 407
Working with a Fun but Complicated Example: A Chessboard. 408
Using the Arrays Class . 416
Filling an array. 417
Copying an array. 417
Sorting an array. 419
Searching an array 419
Comparing arrays. 420
Converting arrays to strings. 420
CHAPTER 3: Using the ArrayList Class. 423
Understanding the ArrayList Class. 424
Creating an ArrayList Object . 427
Adding Elements. 428
Accessing Elements. 429
Printing an ArrayList. 430
Using an Iterator. 430
Updating Elements. 432
Deleting Elements. 434
CHAPTER 4: Using the LinkedList Class. 437
Understanding the LinkedList Class. 438
Creating a LinkedList. 442
Adding Items to a LinkedList. 443
Retrieving Items from a LinkedList. 445
Updating LinkedList Items. 446
Removing LinkedList Items . 447
CHAPTER 5: Creating Generic Collection Classes. 449
Why Generics?. 450
Creating a Generic Class. 451
A Generic Stack Class . 453
Using Wildcard-Type Parameters. 457
A Generic Queue Class. 458
Using the Diamond Operator . 462
CHAPTER 6: Using Bulk Data Operations with Collections. 463
Looking At a Basic Bulk Data Operation . 464
Looking Closer at the Stream Interface. 467
Using Parallel Streams. 470
BOOK 5: PROGRAMMING TECHNIQUES . 473
CHAPTER 1: Programming Threads. 475
Understanding Threads. 476
Creating a Thread. 477
Understanding the Thread class. 477
Extending the Thread class . 478
Creating and starting a thread . 480
Implementing the Runnable Interface. 480
Using the Runnable interface . 481
Creating a class that implements Runnable . 481
Using the CountDownApp class . 483
Creating Threads That Work Together. 485
Using an Executor. 489
Synchronizing Methods . 491
Creating a Lock . 496
Coping with Threadus Interruptus. 497
Finding out whether you’ve been interrupted . 498
Aborting the countdown . 499
CHAPTER 2: Using Regular Expressions. 505
Creating a Program for Experimenting with Regular Expressions. 506
Performing Basic Character Matching. 509
Matching single characters . 509
Using predefined character classes. 509
Using custom character classes . 512
Using ranges. 513
Using negation. 514
Matching multiple characters . 514
Using escapes 516
Using parentheses to group characters. 516
Using the pipe symbol . 518
Using Regular Expressions in Java Programs . 519
Understanding the String problem. 519
Using regular expressions with the String class. 520
Using the Pattern and Matcher classes. 521
CHAPTER 3: Using Recursion. 523
Calculating the Classic Factorial Example . 523
The nonrecursive solution. 524
The recursive solution .524
Displaying Directories. 526
Writing Your Own Sorting Routine. 530
Understanding how Quicksort works. 530
Using the sort method. 531
Using the partition method. 532
Putting it all together . 534
CHAPTER 4: Working with Dates and Times . 539
Pondering How Time is Represented. 540
Picking the Right Date and Time Class for Your Application. 541
Using the now Method to Create a Date-Time Object. 542
Using the parse Method to Create a Date-Time Object. 544
Using the of Method to Create a Date-Time Object. 545
Using the Month enumeration . 545
Using the ZoneId class . 547
Using the ZoneOffset class. 548
Looking Closer at the LocalDate Class. 548
Extracting Information About a Date. 550
Comparing Dates. 551
Calculating with Dates . 552
Formatting Dates. 554
Looking at a Fun Birthday Calculator. 556
BOOK 6: JAVAFX. 561
CHAPTER 1: Hello, JavaFX!. 563
Perusing the Possibilities of JavaFX. 564
Looking at a Simple JavaFX Program . 566
Importing JavaFX Packages . 567
Extending the Application Class . 568
Launching the Application. 569
Overriding the start Method. 570
Creating a Button . 572
Handling an Action Event. 573
Creating a Layout Pane. 574
Making a Scene . 576
Setting the Stage. 576
Examining the Click Counter Program. 577
CHAPTER 2: Handling Events. 583
Examining Events . 584
Handling Events. 585
Implementing the EventHandler Interface . 587
Handling Events with Inner Classes. 591
Handling Events with Anonymous Inner Classes. 593
Using Lambda Expressions to Handle Events. 596
CHAPTER 3: Setting the Stage and Scene Layout. 603
Examining the Stage Class. 604
Examining the Scene Class. 607
Switching Scenes. 609
Creating an Alert Box . 613
Exit, Stage Right. 618
Creating a Close button . 619
Handling the CloseRequest event. 621
Putting it all together . 622
CHAPTER 4: Using Layout Panes to Arrange Your Scenes. 625
Working with Layout Panes. 626
Introducing five JavaFX layout panes. 626
Creating layout panes. 626
Combining layout panes. 628
Using the HBox Layout. 628
Spacing Things Out. 630
Adding Space with Margins. 632
Adding Space by Growing Nodes . 633
Using the VBox Layout. 635
Aligning Nodes in a Layout Pane. 637
Making Nodes the Same Width. 638
Using the Flow Layout. 639
Using the Border Layout . 643
Using the GridPane Layout . 645
Sketching out a plan. 646
Creating a grid pane. 647
Working with grid pane constraints. 650
Examining a grid pane example . 652
CHAPTER 5: Getting Input from the User. 659
Using Text Fields. 660
Validating Numeric Data .667
Using Check Boxes . 668
Using Radio Buttons. 671
Looking at a Pizza Order Application. 673
CHAPTER 6: Choosing from a List. 681
Using Choice Boxes. 681
Creating a choice box. 683
Setting a default value . 684
Getting the selected item. 685
Working with Observable Lists . 685
Listening for Selection Changes . 688
Using Combo Boxes . 690
Creating combo boxes. 691
Getting the selected item. 692
Handling combo box events . 693
Using List Views. 694
Creating a list view. 695
Getting the selected items. 696
Using Tree Views. 696
Building a tree. 698
Creating a TreeView control. 701
Getting the selected node . 702
Looking at a complete program that uses a tree view. 704
BOOK 7: WEB PROGRAMMING. 707
CHAPTER 1: Using Java Web Start. 709
Looking at a Simple JavaFX Program . 709
Understanding Java Web Start. 712
Creating a JNLP File. 713
Creating an HTML File to Launch a Java Application . 715
Uploading the Java Web Start Files to Your Web Server. 716
Launching the ClickMe Application Using Java Web Start. 717
Creating an Exception to Allow Java Web
Start Applications to Run. 718
CHAPTER 2: Creating Servlets. 721
Understanding Servlets . 721
Using Tomcat. 723
Installing and configuring Tomcat. 723
Starting and stopping Tomcat. 724
Testing Tomcat. 725
Creating a Simple Servlet. 726
Importing the servlet packages. 726
Extending the HttpServlet class. 726
Printing to a web page . 727
Responding with HTML. 727
Running a Servlet. 730
Improving the HelloWorld Servlet. 730
Getting Input from the User . 732
Working with forms. 732
Using the InputServlet servlet. 734
Using Classes in a Servlet. 735
CHAPTER 3: Using JavaServer Pages. 741
Understanding JavaServer Pages . 742
Using Page Directives. 743
Using Expressions. 744
Using Scriptlets . 746
Using Declarations . 749
Using Classes. 751
CHAPTER 4: Using JavaBeans. 757
Getting to Know JavaBeans . 757
Looking Over a Sample Bean. 759
Using Beans with JSP Pages. 761
Creating bean instances. 761
Getting property values. 763
Setting property values. 764
Viewing a JSP page that uses a bean. 765
Scoping Your Beans . 767
A shopping cart application. 767
The shopping cart page . 768
The BookCart JavaBean . 770
BOOK 8: FILES AND DATABASES. 775
CHAPTER 1: Working with Files. 777
Using the File Class. 777
Knowing the class constructors and methods . 778
Creating a File object. 780
Creating a file. 780
Getting information about a file. 781
Getting the contents of a directory. 781
Renaming files. 782
Deleting a file. 783
Using Command-Line Parameters. 784
Choosing Files in a Swing Application  .785
Creating an Open dialog box. 788
Getting the selected file. 789
Using file filters . 789
Using Path Objects . 792
Creating files with the Paths class. 793
Getting the contents of a directory. 794
Using a File Visitor to Walk a File Tree . 795
CHAPTER 2: Working with File Streams. 799
Understanding Streams. 800
Reading Character Streams. 801
Creating a BufferedReader . 802
Reading from a character stream. 803
Reading the movies.txt file. 804
Writing Character Streams. 807
Connecting a PrintWriter to a text file . 808
Writing to a character stream. 810
Writing the movies.txt file . 810
Reading Binary Streams. 813
Creating a DataInputStream . 815
Reading from a data input stream. 815
Reading the movies.dat file. 817
Writing Binary Streams. 820
Creating a DataOutputStream. 822
Writing to a binary stream. 822
Writing the movies.dat file. 823
CHAPTER 3: Database for $100, Please. 827
Defining a Relational Database. 828
Understanding (and Pronouncing) SQL. 828
Introducing SQL Statements. 829
Creating a SQL Database. 829
Querying a Database . 832
Using a basic select statement . 832
Narrowing the query. 834
Excluding rows. 834
Using singleton selects. 835
Finding what something sounds like . 835
Using column functions. 835
Selecting data from more than one table . 837
Eliminating duplicates. 838
Updating and Deleting Rows. 839
Using the delete statement. 840
Using the update statement . 841
CHAPTER 4: Using JDBC to Connect to a Database. 845
Setting Up a Driver . 845
Connecting to a Database . 846
Querying a Database . 848
Executing a select statement. 849
Navigating through the result set. 849
Getting data from a result set. 850
Putting it all together: A program that reads
from a database. 851
Updating SQL Data. 855
Using an Updatable RowSet Object . 856
Deleting a row. 858
Updating the value of a row column . 858
Inserting a row. 859
CHAPTER 5: Working with XML. 861
Defining XML . 861
Tags. 862
Attributes . 863
The XML declaration. 864
The movies.xml file. 864
Using a DTD. 865
Processing XML in Two Ways: DOM and SAX . 868
Reading a DOM Document . 869
Creating a DocumentBuilderFactory . 870
Configuring the DocumentBuilderFactory. 870
Creating a document builder and the document. 871
Using the getDocument method. 872
Reading DOM Nodes. 872
Processing elements. 874
Getting attribute values. 875
Getting child element values. 876
Putting It All Together: A Program That Lists Movies. 877
INDEX. 881

Bookscreen
e-books shop

0