iglu.util
Class WashingFilterInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.FilterInputStream
              |
              +--iglu.util.WashingFilterInputStream

public class WashingFilterInputStream
extends java.io.FilterInputStream

Filters control characters and high-bit characters from an input stream. This allows text processors to only deal with printable characters. Note that this class assumes the input stream is encoded in ASCII.

Version:
1.0
Author:
Ryan Scherle rscherle@acm.org (concept by Jay Budzik)

Field Summary
private static int EOF
           
private static int NEWLINE
           
private static int RETURN
           
private static int SPACE
           
private static int TAB
           
private static int TILDE
           
 
Fields inherited from class java.io.FilterInputStream
in
 
Fields inherited from class java.io.InputStream
 
Constructor Summary
WashingFilterInputStream(java.io.InputStream in)
          Creates a filtered input stream.
 
Method Summary
static void main(java.lang.String[] args)
          Washes a file and sends the results to stdout.
 int read()
          Reads in a character from the input stream.
 int read(byte[] buffer, int off, int len)
          Reads up to len bytes of data from this input stream into an array of bytes.
static java.lang.String washString(java.lang.String s)
          Washes the contents of a single string.
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EOF

private static final int EOF
See Also:
Constant Field Values

SPACE

private static final int SPACE
See Also:
Constant Field Values

TILDE

private static final int TILDE
See Also:
Constant Field Values

TAB

private static final int TAB
See Also:
Constant Field Values

NEWLINE

private static final int NEWLINE
See Also:
Constant Field Values

RETURN

private static final int RETURN
See Also:
Constant Field Values
Constructor Detail

WashingFilterInputStream

public WashingFilterInputStream(java.io.InputStream in)
Creates a filtered input stream.

Method Detail

read

public int read()
         throws java.io.IOException
Reads in a character from the input stream. If the character is less than 32 (Ascii space) or greater than 126 (Ascii tilde), it is converted to a space. However, newlines, tabs, and carriage returns (Ascii 9, 10, 13) are kept.

Overrides:
read in class java.io.FilterInputStream
java.io.IOException

read

public int read(byte[] buffer,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from this input stream into an array of bytes. This method blocks until some input is available.

Overrides:
read in class java.io.FilterInputStream
java.io.IOException

washString

public static java.lang.String washString(java.lang.String s)
Washes the contents of a single string.


main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Washes a file and sends the results to stdout.

java.io.IOException