1 7 8 package com.sun.imageio.spi; 9 10 import java.io.File ; 11 import java.io.RandomAccessFile ; 12 import java.util.Locale ; 13 import javax.imageio.spi.ImageOutputStreamSpi ; 14 import javax.imageio.stream.ImageOutputStream ; 15 import javax.imageio.stream.FileImageOutputStream ; 16 17 public class RAFImageOutputStreamSpi extends ImageOutputStreamSpi { 18 19 private static final String vendorName = "Sun Microsystems, Inc."; 20 21 private static final String version = "1.0"; 22 23 private static final Class outputClass = RandomAccessFile .class; 24 25 public RAFImageOutputStreamSpi() { 26 super(vendorName, version, outputClass); 27 } 28 29 public String getDescription(Locale locale) { 30 return "Service provider that instantiates a FileImageOutputStream from a RandomAccessFile"; 31 } 32 33 public ImageOutputStream createOutputStreamInstance(Object output, 34 boolean useCache, 35 File cacheDir) { 36 if (output instanceof RandomAccessFile ) { 37 try { 38 return new FileImageOutputStream ((RandomAccessFile )output); 39 } catch (Exception e) { 40 e.printStackTrace(); 41 return null; 42 } 43 } else { 44 throw new IllegalArgumentException 45 ("input not a RandomAccessFile!"); 46 } 47 } 48 } 49 | Popular Tags |