1 7 8 package com.sun.imageio.spi; 9 10 import java.io.File ; 11 import java.util.Locale ; 12 import javax.imageio.spi.ImageInputStreamSpi ; 13 import javax.imageio.stream.ImageInputStream ; 14 import javax.imageio.stream.FileImageInputStream ; 15 16 public class FileImageInputStreamSpi extends ImageInputStreamSpi { 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 inputClass = File .class; 23 24 public FileImageInputStreamSpi() { 25 super(vendorName, version, inputClass); 26 } 27 28 public String getDescription(Locale locale) { 29 return "Service provider that instantiates a FileImageInputStream from a File"; 30 } 31 32 public ImageInputStream createInputStreamInstance(Object input, 33 boolean useCache, 34 File cacheDir) { 35 if (input instanceof File ) { 36 try { 37 return new FileImageInputStream ((File )input); 38 } catch (Exception e) { 39 return null; 40 } 41 } else { 42 throw new IllegalArgumentException (); 43 } 44 } 45 } 46 | Popular Tags |