9:29 AM 10/23/2012

Attendance/minute paper: are you making the exam? 

Everyone is welcome, keep the better grade. 

Review:

http://www.cs.indiana.edu/classes/c212-dgerman/fall2012/review.html

Homework Seven due on Thu.

Lab Eight due on Fri. 

Chapter 7: File I/O and Exceptions

Regular Expressions

Two-dimensional arrays/structures. 

Next week: Apache Tomcat (HTTP server)

Explore server-side Java (servlets, JSP, perhaps with JDBC). 

We will also look at applets. 

We will also look at our first Object-Oriented Pattern. 

-bash-4.1$ ls -ld debate.txt
-rw-r--r-- 1 dgerman faculty 100 Oct 23 10:03 debate.txt
-bash-4.1$ cat debate.txt
 This are my thoughts for the day.

I am writing
  some words

 inside


this file.

What else ?
-bash-4.1$ wc debate.txt
 11  18 100 debate.txt
-bash-4.1$

-bash-4.1$ pwd
/u/dgerman/10232012
-bash-4.1$ clear
-bash-4.1$ pwd
/u/dgerman/10232012
-bash-4.1$ ls -l
total 48
-rw-r--r-- 1 dgerman faculty  100 Oct 23 10:03 debate.txt
-rw-r--r-- 1 dgerman faculty   37 Oct 23 10:11 matrix.txt
-rw-r--r-- 1 dgerman faculty 1019 Oct 23 10:05 One.class
-rw-r--r-- 1 dgerman faculty  458 Oct 23 10:05 One.java
-rw-r--r-- 1 dgerman faculty 1369 Oct 23 10:42 Two.class
-rw-r--r-- 1 dgerman faculty  884 Oct 23 10:42 Two.java
-bash-4.1$ cat debate.txt
 This are my thoughts for the day.

I am writing
  some words

 inside


this file.

What else ?
-bash-4.1$ wc debate.txt
 11  18 100 debate.txt
-bash-4.1$ javac One.java
-bash-4.1$ java One debate.txt
java.util.Scanner[delimiters=\p{javaWhitespace}+][position=0][match valid=false][need input=false][source closed=false][skipped=false][group separator=\,][decimal separator=\.][positive prefix=][negative prefix=\Q-\E][positive suffix=][negative suffix=][NaN string=\Q\E][infinity string=\QE]
1. ***( This are my thoughts for the day. )***
2. ***()***
3. ***(I am writing)***
4. ***(  some words)***
5. ***()***
6. ***( inside)***
7. ***()***
8. ***()***
9. ***(this file. )***
10. ***()***
11. ***(What else ? )***
I see 11 lines in this file.
-bash-4.1$ cat One.java
import java.io.*;
import java.util.*;

class One {
  public static void main(String[] args) throws Exception {
    Scanner a = new Scanner(new File(args[0]));
    System.out.println(a);
    int count;
    for (count = 0; a.hasNextLine(); ) {
      String line = a.nextLine();
      count = count + 1;
      System.out.println( count + ". ***(" + line + ")***");
    }
    System.out.println("I see " + count + " lines in this file.");
  }
}
-bash-4.1$ cat Two.java
import java.io.File;
import java.util.Scanner;

public class Two {
  public static void main(String[] args) throws Exception {
    String name = args[0];
    System.out.println("You want to open file: " + name);
    File file = new File(name);
    // System.out.println( file );
    Scanner duke = new Scanner( file );
    System.out.println( duke );
    int tokens = 0, count = 0, sum = 0;
    while (duke.hasNextLine()) {
      String line;
      line = duke.nextLine();
      Scanner maggie = new Scanner(line);
      while (maggie.hasNext()) {
        tokens += 1;
        String token = maggie.next();
        System.out.println("Maggie is discarding: " + token + "(" + tokens + ")");
      }
      sum += line.length();
      count += 1;
      System.out.println( count + ". (" + line + ")");
    }
    System.out.println( count + " " + sum + " " + tokens);
  }
}
-bash-4.1$ javac Two.java
-bash-4.1$ java Two debate.txt
You want to open file: debate.txt
java.util.Scanner[delimiters=\p{javaWhitespace}+][position=0][match valid=false][need input=false][source closed=false][skipped=false][group separator=\,][decimal separator=\.][positive prefix=][negative prefix=\Q-\E][positive suffix=][negative suffix=][NaN string=\Q\E][infinity string=\QE]
Maggie is discarding: This(1)
Maggie is discarding: are(2)
Maggie is discarding: my(3)
Maggie is discarding: thoughts(4)
Maggie is discarding: for(5)
Maggie is discarding: the(6)
Maggie is discarding: day.(7)
1. ( This are my thoughts for the day. )
2. ()
Maggie is discarding: I(8)
Maggie is discarding: am(9)
Maggie is discarding: writing(10)
3. (I am writing)
Maggie is discarding: some(11)
Maggie is discarding: words(12)
4. (  some words)
5. ()
Maggie is discarding: inside(13)
6. ( inside)
7. ()
8. ()
Maggie is discarding: this(14)
Maggie is discarding: file.(15)
9. (this file. )
10. ()
Maggie is discarding: What(16)
Maggie is discarding: else(17)
Maggie is discarding: ?(18)
11. (What else ? )
11 89 18
-bash-4.1$

Thu: midterm makeup

In lab: regular expressions, int[][], ArrayList<ArrayList<Integer>>

--