Java The Complete Reference, Seventh Edition
588 Part II: The Java Library Here is an example that demonstrates theConsoleclass: // Demonstrate Console. import java.io.*; cl ...
Chapter 19: Input/Output: Exploring java.io 589 // If no console available, exit. if(con == null) return; // Read a string and t ...
590 Part II: The Java Library } } if(chars != 0) { ++lines; } } public static void main(String args[]) { FileReader fr; try { if ...
IfeolFlagistrue, the end-of-line characters are returned as tokens. IfeolFlagisfalse, the end- of-line characters are ignored. T ...
default: // FALLSTHROUGH chars += tok.sval.length(); break; } } } public static void main(String args[]) { if (args.length == 0) ...
are recursively located and serialized. Similarly, during the process of deserialization, all of these objects and their referen ...
594 Part II: The Java Library Method Description void close( ) Closes the invoking stream. Further write attempts will generate ...
ObjectInput TheObjectInputinterface extends theDataInputinterface and defines the methods shown in Table 19-8. It supports objec ...
AFileOutputStreamis created that refers to a file named “serial,” and an ObjectOutputStreamis created for that file stream. Thew ...
declaring some of theMyClassinstance variables to betransient. That data is then not saved during serialization. import java.io. ...
This program demonstrates that the instance variables ofobject1andobject2are identical. The output is shown here: object1: s=Hel ...
20 Networking 20 Networking A s all readers know, Java is practically a synonym for Internet programming. There are a number of ...
600 Part II: The Java Library protocols. Many of these will seem familiar to you if you have spent any time surfing the Internet ...
DatagramSocket NetworkInter face URLClassLoader DatagramSocketImpl PasswordAuthentication URLConnection HttpCookie (Added by Jav ...
602 Part II: The Java Library On the Internet, it is common for a single name to be used to represent several machines. In the w ...
Chapter 20: Networking 603 Internet addresses are looked up in a series of hierarchically cached servers. That means that your l ...
Socketdefines several instance methods. For example, aSocketcan be examined at any time for the address and port information ass ...
Chapter 20: Networking 605 String str = (args.length == 0? "osborne.com" : args[0]) + "\n"; // Convert to bytes. byte buf[] = st ...
606 Part II: The Java Library The URL provides a reasonably intelligible form to uniquely identify or address information on the ...
Chapter 20: Networking 607 System.out.println("Host: " + hp.getHost()); System.out.println("File: " + hp.getFile()); System.out. ...
«
27
28
29
30
31
32
33
34
35
36
»
Free download pdf