1 16 17 package org.apache.tester; 18 19 20 import java.io.*; 21 import java.util.*; 22 import javax.servlet.*; 23 import javax.servlet.http.*; 24 25 26 32 33 public class UpperCaseReader extends BufferedReader { 34 35 public UpperCaseReader(BufferedReader reader) throws IOException { 36 super(reader); 37 } 38 39 public int read() throws IOException { 40 int c = super.read(); 41 if (c < 0) 42 return (c); 43 char ch = (char) c; 44 if (Character.isLowerCase(ch)) 45 ch = Character.toUpperCase(ch); 46 return ((int) ch); 47 } 48 49 public int read(char buf[], int off, int len) throws IOException { 50 int n = 0; 51 for (int i = off; i < (off + len); i++) { 52 int c = super.read(); 53 if (c < 0) { 54 if (n == 0) 55 return (-1); 56 break; 57 } 58 char ch = (char) c; 59 if (Character.isLowerCase(ch)) 60 ch = Character.toUpperCase(ch); 61 buf[i] = ch; 62 n++; 63 } 64 return (n); 65 } 66 67 public int read(char buf[]) throws IOException { 68 return (read(buf, 0, buf.length)); 69 } 70 71 } 72 73 | Popular Tags |