1 32 33 package com.imagero.uio.io; 34 35 import java.io.FilterInputStream ; 36 import java.io.IOException ; 37 import java.io.InputStream ; 38 39 42 public abstract class RLEInputStream extends FilterInputStream { 43 boolean finished; 44 45 public RLEInputStream(InputStream in) { 46 super(in); 47 } 48 49 public int available() throws IOException { 50 if (finished) { 51 return 0; 52 } 53 return 1; 54 } 55 56 public void close() throws IOException { 57 } 58 59 public boolean markSupported() { 60 return false; 61 } 62 63 public synchronized void mark(int readlimit) { 64 } 65 66 public synchronized void reset() throws IOException { 67 throw new IOException ("mark/reset not supported"); 68 } 69 70 public int read(byte b[]) throws IOException { 71 return read(b, 0, b.length); 72 } 73 74 public int read(byte b[], int off, int len) throws IOException { 75 int i = off; 76 77 try { 78 for (; i < off + len; i++) { 79 int a = read(); 80 if (a == -1) { 81 i--; 82 break; 83 } 84 b[i] = (byte) a; 85 } 86 } 87 catch (IOException ex) { 88 ex.printStackTrace(); 89 } 90 return i - off; 91 } 92 93 public abstract int read() throws IOException ; 94 95 public static class EndOfLineException extends IOException { 96 public EndOfLineException() { 97 super("RowEndException"); 98 } 99 } 100 101 public static class EndOfBitmapException extends IOException { 102 public EndOfBitmapException() { 103 super("BitmapEndException"); 104 } 105 } 106 107 public static class DeltaRecordException extends IOException { 108 public DeltaRecordException(String s) { 109 super(s); 110 } 111 } 112 } 113 | Popular Tags |