A small program that uses a console to support testing another class : Regex « Utility Classes « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Utility Classes » Regex 
8.24.10.A small program that uses a console to support testing another class
import java.io.Console;

public class MainClass {
  public static void main(String[] args) {
    Console c = System.console();            
    char[] pw;
    pw = c.readPassword("%s""pw: ");      
    for(char ch: pw)
      c.format("%c ", ch);                  
    c.format("\n");

    MyUtility mu = new MyUtility();
    while(true) {
      String name = c.readLine("%s""input?: ");  

      c.format("output: %s \n", mu.doStuff(name));
    }
  }
}

class MyUtility {                           
  String doStuff(String arg1) {
    // stub code
    return "result is " + arg1;
  }
}
8.24.Regex
8.24.1.. Matches any character
8.24.2.\d Matches any digit ("0" - "9")
8.24.3.\s Matches any whitespace character, such as space, tab, or newline
8.24.4.\w Matches any letter ("a" - "z" or "A" - "Z") or digit
8.24.5.Using escape sequence in regular expression.
8.24.6.* Matches zero or more occurrences of the preceding pattern
8.24.7.+ Matches one or more occurrences of the preceding pattern
8.24.8.? Matches zero or one occurrences of the preceding pattern
8.24.9.Flags for regex
8.24.10.A small program that uses a console to support testing another class
8.24.11.Tokenizing with String.split()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.