org.acm.seguin.metrics
Class LineCounter

java.lang.Object
  extended by org.acm.seguin.metrics.LineCounter

public class LineCounter
extends java.lang.Object

Counts the number of lines in a file

Author:
Chris Seguin

Constructor Summary
LineCounter(java.io.File init)
          Constructor for the LineCounter object
 
Method Summary
protected  int countCharacter(int ch, java.io.InputStream in)
          Counts how many lines a character counts as (depends on next character sometimes)
 int countLines()
          Counts the number of lines in a file
static void main(java.lang.String[] args)
          Main program
 int printMessage()
          Prints the message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineCounter

public LineCounter(java.io.File init)
Constructor for the LineCounter object

Parameters:
init - File to count
Method Detail

countLines

public int countLines()
Counts the number of lines in a file

Returns:
The number of lines in the file

printMessage

public int printMessage()
Prints the message

Returns:
The number of lines in the file

countCharacter

protected int countCharacter(int ch,
                             java.io.InputStream in)
                      throws java.io.IOException
Counts how many lines a character counts as (depends on next character sometimes)

Parameters:
ch - The character to be counted
in - The input stream
Returns:
The number to add to the ongoing count
Throws:
java.io.IOException - Thrown if unable to read from the input stream

main

public static void main(java.lang.String[] args)
Main program

Parameters:
args - Command line arguments