Changeset 12318
- Timestamp:
- 01/01/10 10:42:21 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/util/RandomAccessCharacterFile.java
r12317 r12318 59 59 super(null); 60 60 } 61 61 62 62 private byte[] read_buf = new byte[1]; 63 63 … … 73 73 } 74 74 } 75 75 76 76 @Override 77 77 public final int read(byte[] b, int off, int len) throws IOException { … … 163 163 } 164 164 } 165 165 166 166 // dummy reader which we need to call the Pushback constructor 167 167 // because a null value won't work 168 168 private static Reader staticReader = new StringReader(""); 169 169 170 170 private class RandomAccessReader extends PushbackReader { 171 171 … … 180 180 RandomAccessCharacterFile.this.close(); 181 181 } 182 182 183 183 private char[] read_buf = new char[1]; 184 184 … … 186 186 public final int read() throws IOException { 187 187 int n = this.read(read_buf); 188 188 189 189 if (n == 1) 190 190 return read_buf[0]; … … 219 219 return RandomAccessCharacterFile.this.read(cbuf, 0, cbuf.length); 220 220 } 221 221 222 222 @Override 223 223 public final int read(char[] cb, int off, int len) throws IOException { … … 253 253 254 254 final static int BUFSIZ = 4*1024; // setting this to a small value like 8 is helpful for testing. 255 255 256 256 private RandomAccessWriter writer; 257 257 private RandomAccessReader reader; … … 259 259 private RandomAccessOutputStream outputStream; 260 260 private FileChannel fcn; 261 261 262 262 private Charset cset; 263 263 private CharsetEncoder cenc; 264 264 private CharsetDecoder cdec; 265 265 266 266 /** 267 267 * bbuf is treated as a cache of the file content. … … 304 304 outputStream = new RandomAccessOutputStream(); 305 305 } 306 306 307 307 public Writer getWriter() { 308 308 return writer; 309 309 } 310 310 311 311 public PushbackReader getReader() { 312 312 return reader; 313 313 } 314 314 315 315 public PushbackInputStream getInputStream() { 316 316 return inputStream; 317 317 } 318 318 319 319 public OutputStream getOutputStream() { 320 320 return outputStream; 321 321 } 322 322 323 323 public final void close() throws IOException { 324 324 internalFlush(true); 325 325 fcn.close(); 326 326 } 327 327 328 328 public final void flush() throws IOException { 329 329 internalFlush(false); … … 417 417 } 418 418 } 419 419 420 420 public final long position() throws IOException { 421 421 return bbufpos + bbuf.position(); // the logical position within the file. … … 467 467 return pos - off; 468 468 } 469 469 470 470 // a method corresponding to the good ol' ungetc in C. 471 471 // This function may fail when using (combined) character codes that use … … 502 502 position(pos); 503 503 } 504 504 505 505 public final void unreadByte(byte b) throws IOException { 506 506 long pos = position() - 1;
Note: See TracChangeset
for help on using the changeset viewer.