FileDocCategorySizeDatePackage
rot13InputStream.javaAPI DocExample415Sun Jul 06 18:48:30 BST 1997exploringjava.io

rot13InputStream.java

package exploringjava.io;

import java.io.*;

public class rot13InputStream extends FilterInputStream {

	public rot13InputStream ( InputStream i ) {
		super( i );
	}

	public int read() throws IOException { 
		return rot13( in.read() );
	}

	private int rot13 ( int c ) {
		if ( (c >= 'A') && (c <= 'Z') )
			c=(((c-'A')+13)%26)+'A';
		if ( (c >= 'a') && (c <= 'z') )
			c=(((c-'a')+13)%26)+'a';
		return c;
	}
}