org.apache.poi.util.IOUtils.calculateChecksum()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(363)

本文整理了Java中org.apache.poi.util.IOUtils.calculateChecksum()方法的一些代码示例,展示了IOUtils.calculateChecksum()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.calculateChecksum()方法的具体详情如下:
包路径:org.apache.poi.util.IOUtils
类名称:IOUtils
方法名:calculateChecksum

IOUtils.calculateChecksum介绍

[英]Calculate checksum on all the data read from input stream. This should be more efficient than the equivalent code IOUtils.calculateChecksum(IOUtils.toByteArray(stream))
[中]计算从输入流读取的所有数据的校验和。这应该比等效代码IOUtils更有效。calculateChecksum(IOUtils.toByteArray(流))

代码示例

代码示例来源:origin: org.apache.poi/poi-ooxml

XWPFPictureData findPackagePictureData(byte[] pictureData, int format) {
  long checksum = IOUtils.calculateChecksum(pictureData);
  XWPFPictureData xwpfPicData = null;
  /*
   * Try to find PictureData with this checksum. Create new, if none
   * exists.
   */
  List<XWPFPictureData> xwpfPicDataList = packagePictures.get(checksum);
  if (xwpfPicDataList != null) {
    Iterator<XWPFPictureData> iter = xwpfPicDataList.iterator();
    while (iter.hasNext() && xwpfPicData == null) {
      XWPFPictureData curElem = iter.next();
      if (Arrays.equals(pictureData, curElem.getData())) {
        xwpfPicData = curElem;
      }
    }
  }
  return xwpfPicData;
}

代码示例来源:origin: org.apache.poi/poi-ooxml

public void setData(byte[] data) throws IOException {
  OutputStream os = getPackagePart().getOutputStream();
  os.write(data);
  os.close();
  // recalculate now since we already have the data bytes available anyhow
  checksum = IOUtils.calculateChecksum(data);
  origSize = null; // need to recalculate image size
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * check if a picture with this picture data already exists in this presentation
 *
 * @param pictureData The picture data to find in the SlideShow
 * @return {@code null} if picture data is not found in this slideshow
 * @since 3.15 beta 2
 */
@Override
public XSLFPictureData findPictureData(byte[] pictureData) {
  long checksum = IOUtils.calculateChecksum(pictureData);
  byte cs[] = new byte[LittleEndianConsts.LONG_SIZE];
  LittleEndian.putLong(cs, 0, checksum);
  for (XSLFPictureData pic : getPictureData()) {
    if (Arrays.equals(pic.getChecksum(), cs)) {
      return pic;
    }
  }
  return null;
}

代码示例来源:origin: org.apache.poi/poi-ooxml

public Long getChecksum() {
  if (this.checksum == null) {
    byte[] data;
    try (InputStream is = getPackagePart().getInputStream()) {
      data = IOUtils.toByteArray(is);
    } catch (IOException e) {
      throw new POIXMLException(e);
    }
    this.checksum = IOUtils.calculateChecksum(data);
  }
  return this.checksum;
}

代码示例来源:origin: org.apache.poi/poi-ooxml

public Long getChecksum() {
  if (this.checksum == null) {
    InputStream is = null;
    byte[] data;
    try {
      is = getPackagePart().getInputStream();
      data = IOUtils.toByteArray(is);
    } catch (IOException e) {
      throw new POIXMLException(e);
    } finally {
      IOUtils.closeQuietly(is);
    }
    this.checksum = IOUtils.calculateChecksum(data);
  }
  return this.checksum;
}

代码示例来源:origin: org.apache.poi/poi-ooxml

if (origSize == null || checksum == null) {
  byte data[] = getData();
  checksum = IOUtils.calculateChecksum(data);

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

long getChecksum(){
    if(checksum == null){
      byte[] pictureData = getData();
      checksum = IOUtils.calculateChecksum(pictureData);
    }
    return checksum;
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

XWPFPictureData findPackagePictureData(byte[] pictureData, int format) {
  long checksum = IOUtils.calculateChecksum(pictureData);
  XWPFPictureData xwpfPicData = null;
  /*
   * Try to find PictureData with this checksum. Create new, if none
   * exists.
   */
  List<XWPFPictureData> xwpfPicDataList = packagePictures.get(checksum);
  if (xwpfPicDataList != null) {
    Iterator<XWPFPictureData> iter = xwpfPicDataList.iterator();
    while (iter.hasNext() && xwpfPicData == null) {
      XWPFPictureData curElem = iter.next();
      if (Arrays.equals(pictureData, curElem.getData())) {
        xwpfPicData = curElem;
      }
    }
  }
  return xwpfPicData;
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

XWPFPictureData findPackagePictureData(byte[] pictureData, int format)
{
  long checksum = IOUtils.calculateChecksum(pictureData);
  XWPFPictureData xwpfPicData = null;
  /*
   * Try to find PictureData with this checksum. Create new, if none
   * exists.
   */
  List<XWPFPictureData> xwpfPicDataList = packagePictures.get(checksum);
  if (xwpfPicDataList != null) {
    Iterator<XWPFPictureData> iter = xwpfPicDataList.iterator();
    while (iter.hasNext() && xwpfPicData == null) {
      XWPFPictureData curElem = iter.next();
      if (Arrays.equals(pictureData, curElem.getData())) {
        xwpfPicData = curElem;
      }
    }
  } 
  return xwpfPicData;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

public void setData(byte[] data) throws IOException {
  OutputStream os = getPackagePart().getOutputStream();
  os.write(data);
  os.close();
  // recalculate now since we already have the data bytes available anyhow
  checksum = IOUtils.calculateChecksum(data);
  origSize = null; // need to recalculate image size
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * check if a picture with this picture data already exists in this presentation
 */
XSLFPictureData findPictureData(byte[] pictureData){
  long checksum = IOUtils.calculateChecksum(pictureData);
  for(XSLFPictureData pic : getAllPictures()){
    if(pic.getChecksum() == checksum) {
      return pic;
    }
  }
  return null;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * check if a picture with this picture data already exists in this presentation
 *
 * @param pictureData The picture data to find in the SlideShow
 * @return {@code null} if picture data is not found in this slideshow
 * @since 3.15 beta 2
 */
@Override
public XSLFPictureData findPictureData(byte[] pictureData) {
  long checksum = IOUtils.calculateChecksum(pictureData);
  byte cs[] = new byte[LittleEndianConsts.LONG_SIZE];
  LittleEndian.putLong(cs, 0, checksum);
  for (XSLFPictureData pic : getPictureData()) {
    if (Arrays.equals(pic.getChecksum(), cs)) {
      return pic;
    }
  }
  return null;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

public Long getChecksum() {
  if (this.checksum == null) {
    byte[] data;
    try (InputStream is = getPackagePart().getInputStream()) {
      data = IOUtils.toByteArray(is);
    } catch (IOException e) {
      throw new POIXMLException(e);
    }
    this.checksum = IOUtils.calculateChecksum(data);
  }
  return this.checksum;
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

public Long getChecksum() {
  if (this.checksum == null) {
    InputStream is = null;
    byte[] data;
    try {
      is = getPackagePart().getInputStream();
      data = IOUtils.toByteArray(is);
    } catch (IOException e) {
      throw new POIXMLException(e);
    } finally {
      try {
        is.close();
      } catch (IOException e) {
        throw new POIXMLException(e);
      }
    }
    this.checksum = IOUtils.calculateChecksum(data);
  }
  return this.checksum;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

public Long getChecksum() {
  if (this.checksum == null) {
    InputStream is = null;
    byte[] data;
    try {
      is = getPackagePart().getInputStream();
      data = IOUtils.toByteArray(is);
    } catch (IOException e) {
      throw new POIXMLException(e);
    } finally {
      IOUtils.closeQuietly(is);
    }
    this.checksum = IOUtils.calculateChecksum(data);
  }
  return this.checksum;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

if (origSize == null || checksum == null) {
  byte data[] = getData();
  checksum = IOUtils.calculateChecksum(data);

相关文章