1 3 package jodd.io; 4 5 import java.io.IOException ; 6 import java.io.InputStream ; 7 import java.io.Serializable ; 8 9 13 public class AsciiStringInputStream extends InputStream implements Serializable { 14 15 protected int strOffset = 0; 16 protected int available; 17 protected String str; 18 19 public AsciiStringInputStream(String s) { 20 str = s; 21 available = s.length(); 22 } 23 24 public int read() throws IOException { 25 if (available == 0) { 26 return -1; 27 } 28 available--; 29 char c = str.charAt(strOffset); 30 strOffset++; 31 return c; 32 } 33 34 public int available() throws IOException { 35 return available; 36 } 37 } 38 | Popular Tags |