KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > imageio > spi > FileImageOutputStreamSpi


1 /*
2  * @(#)FileImageOutputStreamSpi.java 1.8 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

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