1 6 21 22 package de.schlichtherle.io.rof; 23 24 import java.io.EOFException ; 25 import java.io.IOException ; 26 27 67 public class FilterReadOnlyFile implements ReadOnlyFile { 68 69 70 protected ReadOnlyFile rof; 71 72 76 public FilterReadOnlyFile(ReadOnlyFile rof) { 77 this.rof = rof; 78 } 79 80 public long length() throws IOException { 81 return rof.length(); 82 } 83 84 public long getFilePointer() throws IOException { 85 return rof.getFilePointer(); 86 } 87 88 public void seek(long pos) throws IOException { 89 rof.seek(pos); 90 } 91 92 public int read() throws IOException { 93 return rof.read(); 94 } 95 96 public int read(byte[] b) throws IOException { 97 return read(b, 0, b.length); 98 } 99 100 public int read(byte[] b, int off, int len) throws IOException { 101 return rof.read(b, off, len); 102 } 103 104 public void readFully(byte[] b) throws IOException { 105 readFully(b, 0, b.length); 106 } 107 108 public void readFully(byte[] buf, int off, int len) throws IOException { 109 int n = 0; 110 do { 111 int count = read(buf, off + n, len - n); 112 if (count < 0) 113 throw new EOFException (); 114 n += count; 115 } while (n < len); 116 } 117 118 public int skipBytes(int n) throws IOException { 119 return rof.skipBytes(n); 120 } 121 122 public void close() throws IOException { 123 rof.close(); 124 } 125 } 126 | Popular Tags |