1 23 24 package examples.invoice.applications; 25 26 import java.io.InputStream ; 27 import java.io.OutputStream ; 28 import java.io.IOException ; 29 import java.io.File ; 30 import java.io.FileInputStream ; 31 import java.io.FileNotFoundException ; 32 33 38 class ObsInputStream extends InputStream { 39 private InputStream in; 40 41 public static InputStream observes(String cmdfile) { 42 try { 43 return new ObsInputStream(new FileInputStream (new File (cmdfile))); 44 } catch (FileNotFoundException e) { 45 System.err.println("The commands file cannot be accessed!"); 46 System.exit(-1); 47 return null; 48 } 49 } 50 51 public ObsInputStream(InputStream in) { 52 this.in = in; 53 } 54 55 public int available() throws IOException { 56 return in.available(); 57 } 58 59 public void close() throws IOException { 60 in.close(); 61 } 62 63 public void mark(int readlimit) { 64 in.mark(readlimit); 65 } 66 67 public boolean markSupported() { 68 return in.markSupported(); 69 } 70 71 public int read() throws IOException { 72 int c; 73 c = in.read(); 74 System.out.write(c); 75 return c; 76 } 77 78 public int read(byte[] b) throws IOException { 79 int size = in.read(b); 80 System.out.write(b, 0, size); 81 return size; 82 } 83 84 public int read(byte[] b, int off, int len) throws IOException { 85 int size = in.read(b, off, len); 86 System.out.write(b, off, size); 87 return size; 88 } 89 90 public void reset() throws IOException { 91 in.reset(); 92 } 93 94 public long skip(long n) throws IOException { 95 return in.skip(n); 96 } 97 } 98 | Popular Tags |