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