1 21 package org.apache.derby.client.am; 22 23 import java.io.StringReader ; 24 25 public class AsciiStream extends java.io.InputStream { 26 private java.io.Reader reader_; 27 private String materializedString_; 28 private int charsRead_ = 0; 29 30 public AsciiStream(String materializedString){ 31 this(materializedString,new StringReader (materializedString)); 32 } 33 34 public AsciiStream(String materializedString, java.io.Reader reader) { 35 reader_ = reader; 36 materializedString_ = materializedString; 37 } 38 39 public int read() throws java.io.IOException { 40 int oneChar = reader_.read(); 41 ++charsRead_; 42 if (oneChar != -1) { 44 if(oneChar <= 0x00ff) 45 return oneChar; 46 else 47 return 0x003f; 48 49 } else { 50 return -1; } 52 } 53 54 public int available() { 55 return materializedString_.length() - charsRead_; 56 } 57 } 58 | Popular Tags |