JDK1.7 ImageIO的一个梗

上个星期我的leader就要我看 这个东西了,由于一个星期都在做项目上的东西,没时间看,今天终于把那个事情完结了。。

来脑补一下这个事情:

他们项目组的JDK原来是JDK1.6,现在要用JDK1.7,然后呢,图像处理这一块有点问题。

JDK1.7将encoder,decoder类删除掉了,所以呢代码就有问题了,就要我帮助他们改一改。

今天终于好了!

言归正传,了解下JDK1.7和JDK1.6的差别吧:

encoder --> 写 write

decoder --> 读 read


static BufferedImageread(File input)
Returns a BufferedImage as the result of decoding a supplied File with an ImageReader chosen automatically from among those currently registered.
static BufferedImageread(ImageInputStream stream)
Returns a BufferedImage as the result of decoding a supplied ImageInputStream with an ImageReader chosen automatically from among those currently registered.
static BufferedImageread(InputStream input)
Returns a BufferedImage as the result of decoding a supplied InputStream with an ImageReader chosen automatically from among those currently registered.
static BufferedImageread(URL input)
Returns a BufferedImage as the result of decoding a supplied URL with an ImageReader chosen automatically from among those currently registered.

  • read
    public static BufferedImage read(ImageInputStream stream)
                              throws IOException
    Returns a BufferedImage as the result of decoding a supplied ImageInputStream with an ImageReader chosen automatically from among those currently registered. If no registered ImageReader claims to be able to read the stream, null is returned.

    Unlike most other methods in this class, this method does close the provided ImageInputStream after the read operation has completed, unless null is returned, in which case this method does not close the stream.

    Parameters:
    stream - an ImageInputStream to read from.
    Returns:
    a BufferedImage containing the decoded contents of the input, or null.
    Throws:
    IllegalArgumentException - if stream is null.
    IOException - if an error occurs during reading.

static booleanwrite(RenderedImage im, String formatName, File output)
Writes an image using an arbitrary ImageWriter that supports the given format to a File.
static booleanwrite(RenderedImage im, String formatName, ImageOutputStream output)
Writes an image using the an arbitrary ImageWriter that supports the given format to an ImageOutputStream.
static booleanwrite(RenderedImage im, String formatName, OutputStream output)
Writes an image using an arbitrary ImageWriter that supports the given format to an OutputStream.

  • public static boolean write(RenderedImage im,
                String formatName,
                File output)
                         throws IOException
    Writes an image using an arbitrary ImageWriter that supports the given format to a File. If there is already a File present, its contents are discarded.
    Parameters:
    im - a RenderedImage to be written.
    formatName - a String containg the informal name of the format.
    output - a File to be written to.
    Returns:
    false if no appropriate writer is found.
    Throws:
    IllegalArgumentException - if any parameter is null.
    IOException - if an error occurs during writing.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值