V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
CheungKe
V2EX  ›  Java

如何捕获 com.drew.lang.BufferBoundsException 异常,或者不让它输出

  •  
  •   CheungKe · 2015-09-01 11:08:16 +08:00 · 2677 次点击
    这是一个创建于 3369 天前的主题,其中的信息可能已经有所发展或是发生改变。

    保存源码位置

    Metadata metadata = ImageMetadataReader.readMetadata (bin );
    

    错误信息

    com.drew.lang.BufferBoundsException: Attempt to read from beyond end of underlying data source (requested index: 6, requested count: 2, max index: 5 )
    at com.drew.lang.ByteArrayReader.validateIndex (ByteArrayReader.java:68 )
    at com.drew.lang.RandomAccessReader.getInt16 (RandomAccessReader.java:205 )
    at com.drew.imaging.tiff.TiffReader.processTiff (TiffReader.java:53 )
    at com.drew.metadata.exif.ExifReader.extract (ExifReader.java:88 )
    at com.drew.metadata.exif.ExifReader.readJpegSegments (ExifReader.java:73 )
    at com.drew.imaging.jpeg.JpegMetadataReader.processJpegSegmentData (JpegMetadataReader.java:126 )
    at com.drew.imaging.jpeg.JpegMetadataReader.process (JpegMetadataReader.java:118 )
    at com.drew.imaging.jpeg.JpegMetadataReader.readMetadata (JpegMetadataReader.java:69 )
    at com.drew.imaging.jpeg.JpegMetadataReader.readMetadata (JpegMetadataReader.java:76 )
    at com.drew.imaging.ImageMetadataReader.readMetadata (ImageMetadataReader.java:98 )

    catch (Exception e ) 尝试过无法捕获

    <dependency>
        <groupId>com.drewnoakes</groupId>
        <artifactId>metadata-extractor</artifactId>
        <version>2.8.1</version>
    </dependency>
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5252 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 01:23 · PVG 09:23 · LAX 17:23 · JFK 20:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.