Java Swing Icon iconFromStream(final InputStream in)

Here you can find the source of iconFromStream(final InputStream in)

Description

icon From Stream

License

Open Source License

Declaration

public static ImageIcon iconFromStream(final InputStream in) throws IOException 

Method Source Code


//package com.java2s;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.swing.ImageIcon;

public class Main {
    public static ImageIcon iconFromStream(final InputStream in) throws IOException {
        if (in == null) {
            throw new IllegalArgumentException("Stream must not be null");
        }/*from w w w  .  j  a v a 2s. c o m*/
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        final byte[] buffer = new byte[1024];
        int read;
        while ((read = in.read(buffer)) > 0) {
            out.write(buffer, 0, read);
        }
        in.close();
        return new ImageIcon(out.toByteArray());
    }
}

Related

  1. getScaledIcon(String resourceName, int width, int height)
  2. getSize(String graphIconPath)
  3. getTransparentIcon(int width)
  4. getVerBumpIcon()
  5. grayIcon(Icon icon)
  6. item(String name, Icon icon)
  7. loadIcon(Class pRootClass, String strPath)
  8. loadIcon(ClassLoader classLoader, String path)
  9. loadIcon(String icon)