1 31 package org.pdfbox.ttf; 32 33 import java.io.File ; 34 import java.io.FileNotFoundException ; 35 import java.io.IOException ; 36 import java.io.RandomAccessFile ; 37 38 import org.pdfbox.cos.COSStream; 39 40 46 public class RAFDataStream extends TTFDataStream 47 { 48 private RandomAccessFile raf = null; 49 59 public RAFDataStream(String name, String mode) throws FileNotFoundException 60 { 61 raf = new RandomAccessFile ( name, mode ); 62 } 63 64 74 public RAFDataStream(File file, String mode) throws FileNotFoundException 75 { 76 raf = new RandomAccessFile ( file, mode ); 77 } 78 79 85 public short readSignedShort() throws IOException 86 { 87 return raf.readShort(); 88 } 89 90 95 public long getCurrentPosition() throws IOException 96 { 97 return raf.getFilePointer(); 98 } 99 100 112 public COSStream getCOSStream() 113 { 114 COSStream retval = null; 115 116 retval = new COSStream(raf); 117 118 return retval; 119 } 120 121 126 public void close() throws IOException 127 { 128 raf.close(); 129 raf = null; 130 } 131 132 137 public int read() throws IOException 138 { 139 return raf.read(); 140 } 141 142 148 public int readUnsignedShort() throws IOException 149 { 150 return raf.readUnsignedShort(); 151 } 152 153 158 public long readLong() throws IOException 159 { 160 return raf.readLong(); 161 } 162 163 169 public void seek(long pos) throws IOException 170 { 171 raf.seek( pos ); 172 } 173 174 185 public int read(byte[] b, 186 int off, 187 int len) 188 throws IOException 189 { 190 return raf.read(b,off,len); 191 } 192 } 193 | Popular Tags |