Example usage for javax.imageio IIOException printStackTrace

List of usage examples for javax.imageio IIOException printStackTrace

Introduction

In this page you can find the example usage for javax.imageio IIOException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:net.technicpack.launchercore.install.InstalledPack.java

private boolean loadCachedImage(AtomicReference<BufferedImage> image, File file, String url, String md5) {
    try {//w ww  .  j a  v  a 2s. co  m
        if (!file.exists())
            return false;

        boolean reloadImage = (url.isEmpty() || md5.isEmpty());

        if (!reloadImage) {
            String fileMd5 = MD5Utils.getMD5(file);

            if (fileMd5 != null && !fileMd5.isEmpty())
                reloadImage = fileMd5.equalsIgnoreCase(md5);
        }

        if (reloadImage) {
            BufferedImage newImage;
            newImage = ImageIO.read(file);
            image.set(newImage);
            return true;
        }
    } catch (IIOException e) {
        Utils.getLogger().log(Level.INFO, "Failed to load image " + file.getAbsolutePath() + " from file.");
    } catch (IOException e) {
        e.printStackTrace();
    }

    return false;
}

From source file:org.spoutcraft.launcher.technic.PackInfo.java

private boolean buildImage(AtomicReference<BufferedImage> image, String name, String url, String md5, int width,
        int height) {
    File assets = new File(Utils.getAssetsDirectory(), "packs");
    File packs = new File(assets, getName());
    packs.mkdirs();/*from   w w w.j  av  a2s  .  c o m*/
    File temp = new File(packs, name);

    try {
        if (temp.exists() && (url.isEmpty() || md5.equals("") || MD5Utils.getMD5(temp).equalsIgnoreCase(md5))) {
            BufferedImage newImage;
            if (width > 0 && height > 0) {
                newImage = ImageUtils.scaleImage(ImageIO.read(temp), width, height);
            } else {
                newImage = ImageIO.read(temp);
            }
            image.set(newImage);
            return true; // We have successfully loaded the one from the
                         // file, with the correct md5
        }
    } catch (IIOException e) {
        Launcher.getLogger().log(Level.INFO,
                "Failed to load image " + temp.getAbsolutePath() + " from file, attempting download");
    } catch (IOException e) {
        e.printStackTrace(); // Failed to load image from file for some
                             // reason, continue on and debug the stack
                             // trace
    }

    downloadImage(image, url, temp, width, height, md5);
    return false;
}