plz provide full answer......otherwise i will dislike !
605 java.util Part 1: The Collections Framework Chapter 19 The following example demonstrates Properties. It creates a property list in which the used as the default properties for the new instance. In this case, if you call getProperty("foo") on a given Properties object, and "foo" does not exist, Java looks for "foo" in the default Properties object. This allows for arbitrary nesting of levels of default properties. keys are the names of states and the values are the names of their capitals. Notice that the attempt to find the capital for Florida includes a default value. // Demonstrate a Property list. import java.util.; Part II class PropDemo public static void main(String args[]) { Properties capitals = new Properties(); capitals.put("Illinois", "Springfield"); capitals.put("Missouri", "Jefferson City": capitals.put("Washington", "Olympia"); capitals.put("California", "Sacramento); capitals.put("Indiana". "Indianapolis"); 17 Get a set-view of the keys. Set<?> states = capitals.keySet(); 00 15 such // Show all of the states and capitals. for (Object name : states) System.out.println("The capital of + name + " is + capitals.get Property ((String) name) 2 System.out.println(); // Look for state not in list -- specify default. String str = capitals.get Property ("Florida", "Not Found"); System.out.println("The capital of Florida is " + str + "."); } } The output from this program is shown here: sobre o The capital of Missouri is Jefferson City. The capital of Illinois is Springfield. The capital of Indiana is Indianapolis. The capital of California is Sacramento. The capital of Washington is Olympia. The capital of Florida is Not Found. Since Florida is not in the list, the default value is used. Although it is perfectly valid to use a default value when you call get Property, as the preceding example shows, there is a better way of handling default values for most applications of property lists. For greater flexibility, specify a default property list when M
java.util Part 1: The Collections Framework Chapter 19 used as the default properties for the new instance. In this case, if you call getProperty("foo") on a given Properties object, and "foo" does not exist, Java looks for "foo" in the default Properties object. This allows for arbitrary nesting of levels of default properties. The following example demonstrates Properties. It creates a property list in which the keys are the names of states and the values are the names of their capitals. Notice that the attempt to find the capital for Florida includes a default value. // Demonstrate a Property list. import java.util. class PropDemo ! public static void main(String args[]) { Properties capitals = new Properties(); capitals.put("Illinois", "Springfield"); capitals.put("Missouri", "Jefferson City"); capitals.put("Washington". "Olympia"), capitals.put("California", "Sacramento"); capitals.put("Indiana", "Indianapolis"); // Get a set-view of the keys. Set<?> states = capitals.keySet(): Part 11 17 Show all of the states and capitals. for (object name : states) System.out.println("The capital of name + " is capitals.get Property (String) name) System.out.println(); // Look for state not in list -- specify default. String str = capitals.get Property("Florida", "Not Found"); System.out.println("The capital of Florida is " + str + "."); 1 The output from this program is shown here: The capital of Missouri is Jefferson City. The capital of Illinois is Springfield. The capital of Indiana is Indianapolis. The capital of California is Sacramento. The capital of Washington is Olympia The capital of Florida is Not Found. Since Florida is not in the list, the default value is used. Although it is perfectly valid to use a default value when you call getProperty(), as the preceding example shows, there is a better way of handling default values for most applications of property lists. For greater flexibility, specify a default property list when
709 Input/Output: Exploring java.io Chapter 21 Console supplies no constructors. Instead, a Console object is obtained by calling System.console(), which is shown here: static Console console() If a console is available, then a reference to it is returned. Otherwise, null is returned. A console will not be available in all cases. Thus, if null is returned, no console I/O is possible. Console defines the methods shown in Table 21-5. Notice that the input methods, such as readLine(), throw IOError if an input error occurs. IOError is a subclass of Error. It indicates an I/O failure that is beyond the control of your program. Thus, you will not normally catch an IOError. Frankly, if an 10Error is thrown while accessing the console, it usually means there has been a catastrophic system failure. Part II Method void flush() Clopes Stainly Console format(String fotString, Object...args) Console printf(String fmtString, Object...args) Reader reader) String readLine() in the ha String readLine(String fotString, Object...args) Description Causes buffered output to be written physically to the console. Writes args to the console using the format specified by fmtString Writes args to the console using the format specified by fmtString Returns a reference to a Reader connected to the console. Reads and returns a string entered at the keyboard. Input stops when the user presses ENTER. If the end of the console input stream has been reached, null is returned. An IOError is thrown on failure. Displays a prompting string formatted as specified by fmtString and args, and then reads and returns a string entered at the keyboard. Input stops when the user presses ENTER. If the end of the console input stream has been reached, null is returned. An IOError is thrown on failure. Reads a string entered at the keyboard. Input stops when the user presses ENTER. The string is not displayed. If the end of the console input stream has been reached, null is returned. An IOError is thrown on failure. Displays a prompting string formatted as specified by fmtString and args, and then reads a string entered at the keyboard. Input stops when the user presses ENTER. The string is not displayed. If the end of the console input stream has been reached, null is returned. An IOError is thrown on failure. char[] readPassword() char[readPassword(String fotString, Object... args) Returns a reference to a Writer connected to the console. Print Writer writer() Table 21-5 The Methods Defined by Console
plz provide full answer......otherwise i will dislike !
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am