Summary of category and summary of category
1. Constructor
Upload (File source)
Merge (InputStream source)
Trim (String source)
Reference: http://blog.sina.com.cn/s/blog_7014ad5c01018sov.htm2.method
1 bytes in = new bytes (System. in); // enable scanner 2 // 1. hasNext () 3 System. out. println (in. hasNext (); // output time: the first input data receives the "Save and wrap" command (that is, "Carriage Return"). 4 5 // 2. View "Default split method" 6 Pattern p = in. delimiter (); 7 System. out. println (p);/** output: \ p {javaWhitespace} + <white space> */8 9 // 3. Modify "Default split mode" 10 p = Pattern. compile ("_"); 11 in. useDelimiter (p); // modify next (), nextXXX () (except nextLine). The default "segmentation method" 12 System. out. println ("[test splitting method] enter the test string;"); 13 St Ring s = in. next ();/** input: a_ B _c */14 System. out. println (s);/** output; changed (changed to '_'): "a" | not changed (default 'space '): "a_ B _c" */15 16 // 4. Differences between next () and nextLine () 17 System. out. println ("test next and nextLine] enter the test string;"); 18 // accept input 19 s = in. next ();/** input: a_ B _c */20 // s = "a", move the cursor to c and then space 21 // is the cursor at the beginning of the line? NO --> do not accept input (return the part after c in the previous line ("a_ B _c") -- Null String) 22 s = in. nextLine (); // s = "", line feed 23 // is the cursor at the beginning of the line? YES --> Accept input 24 s = in. nextLine ();/** input: a_ B _c */25 // s = "a_ B _c", line feed 26/** 27 * conclusion: 28 * similarities: "Save and wrap" condition -- press ENTER 29 * different points: scan mode, split mode 30 **/31 // 5, close () 32 in. close (); // close the scanner