FileDocCategorySizeDatePackage
PrintableInputStream.javaAPI DocExample874Sat Feb 04 05:44:02 GMT 2006com.elharo.io

PrintableInputStream

public class PrintableInputStream extends FilterInputStream

Fields Summary
Constructors Summary
public PrintableInputStream(InputStream in)

    super(in);
  
Methods Summary
public intread()

  
    int b = in.read();
    // printing, ASCII characters
    if (b >= 32 && b <= 126) return b;
    else if (b == '\n" || b == '\r" || b == '\t") return b;
    // nonprinting characters
    else return '?"; 

  
public intread(byte[] data, int offset, int length)

  
    int result = in.read(data, offset, length);
    for (int i = offset; i < offset+result; i++) {
      // Do nothing with the printing characters.
      if (data[i] == '\n"|| data[i] == '\r" || data[i] == '\t" || data[i] == -1) ;
      // nonprinting characters
      else if (data[i] < 32 || data[i] > 126) data[i] = (byte) '?";
    }
    return result;