Java 类javax.imageio.stream.FileCacheImageInputStream 实例源码

项目:OpenJSharp    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:jdk8u-jdk    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:openjdk-jdk10    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:openjdk9    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:jdk8u_jdk    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:infobip-open-jdk-8    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:jdk8u-dev-jdk    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:jdk7-jdk    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:openjdk-source-code-learn    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:OLD-OpenJDK8    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:openjdk-jdk7u-jdk    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:openjdk-icedtea7    文件:InputStreamImageInputStreamSpi.java   
public ImageInputStream createInputStreamInstance(Object input,
                                                  boolean useCache,
                                                  File cacheDir)
    throws IOException {
    if (input instanceof InputStream) {
        InputStream is = (InputStream)input;

        if (useCache) {
            return new FileCacheImageInputStream(is, cacheDir);
        } else {
            return new MemoryCacheImageInputStream(is);
        }
    } else {
        throw new IllegalArgumentException();
    }
}
项目:viskit    文件:NetworkDicomImageListViewModelElement.java   
@Override
protected DicomObject getBackendDicomObject() {
    checkInitialized();
    try {

        URLConnection connection = url.openConnection();
        connection.setUseCaches(true);
        connection.setDefaultUseCaches(true);

        InputStream is = connection.getInputStream();
        // mark/reset not supported for url so using FileCacheImageInputStream
        DicomInputStream din = new DicomInputStream(new FileCacheImageInputStream(is, null));

        try {
            DicomObject dicomObject = din.readDicomObject();
            return dicomObject;
        } finally {
            din.close();
        }
    } catch (IOException e) {
        // TODO return error object instead?
        throw new IllegalStateException("error reading DICOM object from " + url, e);
    }
}
项目:lams    文件:BufferedImageHttpMessageConverter.java   
private ImageInputStream createImageInputStream(InputStream is) throws IOException {
    if (this.cacheDir != null) {
        return new FileCacheImageInputStream(is, cacheDir);
    }
    else {
        return new MemoryCacheImageInputStream(is);
    }
}
项目:openjdk-jdk10    文件:FileCacheImageInputStreamNullTest.java   
public static void main (String[] args) throws Exception {
    boolean gotIAE = false;
    try {
        FileCacheImageInputStream fciis =
            new FileCacheImageInputStream(null, null);
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }

    if (!gotIAE) {
        throw new RuntimeException
            ("Failed to get IllegalArgumentException!");
    }
}
项目:spring4-understanding    文件:BufferedImageHttpMessageConverter.java   
private ImageInputStream createImageInputStream(InputStream is) throws IOException {
    if (this.cacheDir != null) {
        return new FileCacheImageInputStream(is, cacheDir);
    }
    else {
        return new MemoryCacheImageInputStream(is);
    }
}
项目:jdk8u_jdk    文件:FileCacheImageInputStreamNullTest.java   
public static void main (String[] args) throws Exception {
    boolean gotIAE = false;
    try {
        FileCacheImageInputStream fciis =
            new FileCacheImageInputStream(null, null);
    } catch (IllegalArgumentException e) {
        gotIAE = true;
    }

    if (!gotIAE) {
        throw new RuntimeException
            ("Failed to get IllegalArgumentException!");
    }
}
项目:class-guard    文件:BufferedImageHttpMessageConverter.java   
private ImageInputStream createImageInputStream(InputStream is) throws IOException {
    if (this.cacheDir != null) {
        return new FileCacheImageInputStream(is, cacheDir);
    }
    else {
        return new MemoryCacheImageInputStream(is);
    }
}
项目:openjdk-jdk10    文件:ReadBitsTest.java   
public static void main(String[] args) throws IOException {
    byte[] buffer = new byte[] {(byte)169, (byte)85}; // 10101001 01010101
    InputStream ins = new ByteArrayInputStream(buffer);
    ImageInputStream in = new FileCacheImageInputStream(ins,null);

    if (in.getBitOffset() != 0) {
        throw new RuntimeException("Initial bit offset != 0!");
    }

    int bit0 = in.readBit(); // 1
    if (bit0 != 1) {
        throw new RuntimeException("First bit != 1");
    }
    if (in.getBitOffset() != 1) {
        throw new RuntimeException("Second bit offset != 1");
    }

    long bits1 = in.readBits(5); // 01010 = 10
    if (bits1 != 10) {
        throw new RuntimeException("Bits 1-5 != 10 (= " + bits1 + ")");
    }
    if (in.getBitOffset() != 6) {
        throw new RuntimeException("Third bit offset != 6");
    }

    int bit1 = in.readBit(); // 0
    if (bit1 != 0) {
        throw new RuntimeException("Bit 6 != 0");
    }
    if (in.getBitOffset() != 7) {
        throw new RuntimeException("Third bit offset != 7");
    }

    long bits2 = in.readBits(8); // 10101010 = 170
    if (bits2 != 170) {
        throw new RuntimeException("Bits 7-14 != 170 (= " + bits2 + ")");
    }
    if (in.getBitOffset() != 7) {
        throw new RuntimeException("Fourth bit offset != 7");
    }

    int bit2 = in.readBit(); // 1
    if (bit2 != 1) {
        throw new RuntimeException("Bit 15 != 1");
    }
    if (in.getBitOffset() != 0) {
        throw new RuntimeException("Fifth bit offset != 0");
    }

    in.close();
}
项目:jdk8u_jdk    文件:ReadBitsTest.java   
public static void main(String[] args) throws IOException {
    byte[] buffer = new byte[] {(byte)169, (byte)85}; // 10101001 01010101
    InputStream ins = new ByteArrayInputStream(buffer);
    ImageInputStream in = new FileCacheImageInputStream(ins,null);

    if (in.getBitOffset() != 0) {
        throw new RuntimeException("Initial bit offset != 0!");
    }

    int bit0 = in.readBit(); // 1
    if (bit0 != 1) {
        throw new RuntimeException("First bit != 1");
    }
    if (in.getBitOffset() != 1) {
        throw new RuntimeException("Second bit offset != 1");
    }

    long bits1 = in.readBits(5); // 01010 = 10
    if (bits1 != 10) {
        throw new RuntimeException("Bits 1-5 != 10 (= " + bits1 + ")");
    }
    if (in.getBitOffset() != 6) {
        throw new RuntimeException("Third bit offset != 6");
    }

    int bit1 = in.readBit(); // 0
    if (bit1 != 0) {
        throw new RuntimeException("Bit 6 != 0");
    }
    if (in.getBitOffset() != 7) {
        throw new RuntimeException("Third bit offset != 7");
    }

    long bits2 = in.readBits(8); // 10101010 = 170
    if (bits2 != 170) {
        throw new RuntimeException("Bits 7-14 != 170 (= " + bits2 + ")");
    }
    if (in.getBitOffset() != 7) {
        throw new RuntimeException("Fourth bit offset != 7");
    }

    int bit2 = in.readBit(); // 1
    if (bit2 != 1) {
        throw new RuntimeException("Bit 15 != 1");
    }
    if (in.getBitOffset() != 0) {
        throw new RuntimeException("Fifth bit offset != 0");
    }

    in.close();
}
项目:passage    文件:CSVTiledImagePlugIn.java   
/**
 * Takes the URL to a csv file and parses it into OMScaledRasters, adding
 * them to the tiles HashSet.
 */
protected void loadTiles(String csvFileName) {
    int imageCount = 0;

    if (csvFileName != null) {
        try {
            tilefile = new CSVFile(csvFileName);
            tilefile.setHeadersExist(fileHasHeader);
            tilefile.loadData(false);
            // MediaTracker tracker = new MediaTracker(component); // Create
            // a media tracker

            Iterator records = tilefile.iterator();
            while (records.hasNext()) {
                Vector record = (Vector) records.next();

                if (DEBUG) {
                    Debug.output("CSVTIPI: record: " + record);
                }

                String imageURLString = null;

                try {

                    float ullat = ((Double) record.get(ullatIndex)).floatValue();
                    float ullon = ((Double) record.get(ullonIndex)).floatValue();
                    float lrlat = ((Double) record.get(lrlatIndex)).floatValue();
                    float lrlon = ((Double) record.get(lrlonIndex)).floatValue();
                    imageURLString = (String) record.get(urlIndex);

                    URL imageURL = PropUtils.getResourceOrFileOrURL(imageURLString);

                    FileCacheImageInputStream fciis = new FileCacheImageInputStream(imageURL.openStream(), null);
                    BufferedImage fileImage = ImageIO.read(fciis);

                    // ImageIcon ii = new ImageIcon(imageURL);
                    // Image fileImage = ii.getImage();

                    // try {
                    // tracker.addImage(fileImage, imageCount);
                    // tracker.waitForID(imageCount);
                    // } catch (Exception e) {
                    // if (Debug.debugging("csvtiledimage")) {
                    // e.printStackTrace();
                    // }
                    // } // Catch errors

                    OMScalingRaster omsr = new OMScalingRaster(ullat, ullon, lrlat, lrlon, fileImage);
                    tiles.add(omsr);
                    imageCount++;

                } catch (MalformedURLException innerMurle) {
                    Debug.error("CSVTiledImagePlugIn: image tile path not valid: "
                            + imageURLString + ", skipping...");
                } catch (ArrayIndexOutOfBoundsException aioobe) {
                    Debug.error("CSVTiledImagePlugIn: having trouble reading line ("
                            + imageCount
                            + "), skipping...\n"
                            + aioobe.getMessage());
                } catch (IOException ioe) {
                    Debug.error("CSVTiledImagePlugIn: having trouble reading line ("
                            + imageCount
                            + "), skipping...\n"
                            + ioe.getMessage());
                }
            }

        } catch (MalformedURLException murle) {
            Debug.error("CSVTiledImagePlugIn: CSV tile file not valid: "
                    + csvFileName);
        }
    }
}
项目:passage    文件:WorldFileImageReader.java   
public static BufferedImage getImageIOImage(URL fileURL) throws IOException {
    FileCacheImageInputStream fciis = new FileCacheImageInputStream(fileURL.openStream(), null);
    BufferedImage fileImage = ImageIO.read(fciis);
    return fileImage;
}