examples/Calc.java
public class Calc {

  public static void main(String[] args) {
    Number c = add(2, 3);
    System.out.println(c);
  }

  public static Integer add(Integer a, Integer b) {
    /* System.out.println(a);
    System.out.println(b); */
    return a+b;
  }
}


examples/Cat.java
import java.io.*;

/**
    This class demonstrates how to read a line of text from the keyboard
    Based on http://www.abbeyworkshop.com/howto/java/readLine/ReadLine.java
*/
public class Cat{
    public static void main(String[] args){
        try {
            String CurLine = ""; // Line read from standard in

            InputStreamReader converter = new InputStreamReader(System.in);
            BufferedReader in = new BufferedReader(converter);

            CurLine = in.readLine();
            while (CurLine != null){
                System.out.println(CurLine);
                CurLine = in.readLine();
            }
        }catch (IOException e){
            System.out.println("IO Exception\n");
        }
    }
}

examples/Grep.java
import java.io.*;
import java.util.regex.*;

/**
    This class demonstrates how to read a line of text from the keyboard
    Based on http://www.abbeyworkshop.com/howto/java/readLine/ReadLine.java
*/
public class Grep{
    public static void main(String[] args){
        try {
            Pattern pattern = Pattern.compile(args[0]);

            String line = ""; 

            InputStreamReader converter = new InputStreamReader(System.in);
            BufferedReader in = new BufferedReader(converter);

            line = in.readLine();
            while (line != null){
                Matcher matcher = pattern.matcher(line);
                if(matcher.find()) {
                    System.out.println(line);
                }
                line = in.readLine();
            }
        }catch (IOException e){
            System.out.println("IO Exception\n");
        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println("Usage: java Grep REGEX   (and then type strings on STDIN, Ctr-D to exit)\n");
        }
    }
}

examples/ReadFile.java
import java.io.*;

/**
    Source: http://www.abbeyworkshop.com/howto/java/readFile/ReadFile.java
*/

public class ReadFile{
    public static void main(String[] args){
        try {
			
			/*	Sets up a file reader to read the file passed on the command
				line one character at a time */
			FileReader input = new FileReader(args[0]);
            
			/* Filter FileReader through a Buffered read to read a line at a
			   time */
			BufferedReader bufRead = new BufferedReader(input);
			
            String line; 	// String that holds current file line
            int count = 0;	// Line number of count 
            
            // Read first line
            line = bufRead.readLine();
            count++;
            
			// Read through file one line at time. Print line # and line
            while (line != null){
                System.out.println(count+": "+line);
                line = bufRead.readLine();
                count++;
            }
            
            bufRead.close();
			
        }catch (ArrayIndexOutOfBoundsException e){
            /* If no file was passed on the command line, this expception is
			generated. A message indicating how to the class should be
			called is displayed */
			System.out.println("Usage: java ReadFile filename\n");			

		}catch (IOException e){
			// If another exception is generated, print a stack trace
            e.printStackTrace();
        }
        
    }// end main
}
examples/ReadLine.java
import java.io.*;

class ReadLine{
    public static void main(String[] args) throws IOException{
        String CurLine = ""; // Line read from standard in
        
        System.out.println("Enter a line of text (type 'quit' to exit): ");
        InputStreamReader converter = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(converter);

        
        while (!(CurLine.equals("quit"))){
            CurLine = in.readLine();
            
            if (!(CurLine.equals("quit"))){
                System.out.println("You typed: " + CurLine);
            }
        }
    }
}

examples/Regex.java
import java.io.*;
import java.util.regex.*;

public class Regex{
    public static void main(String[] args){
        {
            String line = "STRING"; 
            Pattern pattern = Pattern.compile("S.R");

            Matcher matcher = pattern.matcher(line);
            if(matcher.find()) {
                System.out.println(line);
                System.out.println("Found '" + matcher.group() +
                               "' starting at index " + matcher.start() +
                               " and ending at index " + matcher.end() + ".");
 
            }else{
                System.out.println("*** NO MATCH ***");
            }
        }
	}
}

examples/RegexTestHarness.java
import java.io.*;
import java.util.regex.*;

/*
 * Source: http://java.sun.com/docs/books/tutorial/extra/regex/example-1dot4/RegexTestHarness.java
*/

public final class RegexTestHarness {

    private static String REGEX;
    private static String INPUT;
    private static BufferedReader br;
    private static Pattern pattern;
    private static Matcher matcher;
    private static boolean found;

    public static void main(String[] argv) {
        initResources();
        processTest();
        closeResources();
    }

    private static void initResources() {
       try {
           br = new BufferedReader(new FileReader("regex.txt"));
       }
       catch (FileNotFoundException fnfe) {
            System.out.println("Cannot locate input file! "+fnfe.getMessage());
            System.exit(0);
        }
       try {
           REGEX = br.readLine();
           INPUT = br.readLine();
       } catch (IOException ioe) {}

        pattern = Pattern.compile(REGEX);
        matcher = pattern.matcher(INPUT);

        System.out.println("Current REGEX is: "+REGEX);
        System.out.println("Current INPUT is: "+INPUT);
    }

    private static void processTest() {
        while(matcher.find()) {
            System.out.println("I found the text \"" + matcher.group() +
                               "\" starting at index " + matcher.start() +
                               " and ending at index " + matcher.end() + ".");
            found = true;
        }

        if(!found){
            System.out.println("No match found.");
        }
    }

    private static void closeResources() {
       try{
           br.close();
       }catch(IOException ioe){}
    }
}

examples/SplitString.java
import java.util.*;
/**
 *  This class demonstrates how to use the StringTokenizer class to splitt apart
 *  strings of text.
 *  Source: http://www.abbeyworkshop.com/howto/java/splitString/SplitString.java
 */
class SplitString {

	public static void main(String[] arguments) {
		StringTokenizer ex1, ex2; // Declare StringTokenizer Objects
		int count = 0;

		String strOne = "one two  three      four   five";
		ex1 = new StringTokenizer(strOne); //Split on Space (default)

		while (ex1.hasMoreTokens()) {
			count++;
			System.out.println("Token " + count + " is [" + ex1.nextToken() + "]");
		}

		count = 0; 	// Reset counter
		
		String strTwo = "item one,item two,item three,item four"; // Comma Separated
		ex2 = new StringTokenizer(strTwo, ",");  //Split on comma

		while (ex2.hasMoreTokens()) {
			count++;
			System.out.println("Token " + count + " is [" + ex2.nextToken() + "]");
		}
	}
}