1 18 package org.apache.batik.ext.awt.image.codec; 19 20 import java.io.IOException ; 21 import java.io.OutputStream ; 22 import java.io.RandomAccessFile ; 23 24 27 public class SeekableOutputStream extends OutputStream { 28 29 private RandomAccessFile file; 30 31 42 public SeekableOutputStream(RandomAccessFile file) { 43 if(file == null) { 44 throw new IllegalArgumentException ("SeekableOutputStream0"); 45 } 46 this.file = file; 47 } 48 49 public void write(int b) throws IOException { 50 file.write(b); 51 } 52 53 public void write(byte b[]) throws IOException { 54 file.write(b); 55 } 56 57 public void write(byte b[], int off, int len) throws IOException { 58 file.write(b, off, len); 59 } 60 61 65 public void flush() throws IOException { 66 file.getFD().sync(); 67 } 68 69 public void close() throws IOException { 70 file.close(); 71 } 72 73 public long getFilePointer() throws IOException { 74 return file.getFilePointer(); 75 } 76 77 public void seek(long pos) throws IOException { 78 file.seek(pos); 79 } 80 } 81 | Popular Tags |