Example usage for org.apache.poi.util HexDump dump

List of usage examples for org.apache.poi.util HexDump dump

Introduction

In this page you can find the example usage for org.apache.poi.util HexDump dump.

Prototype


public static String dump(final byte[] data, final long offset, final int index) 

Source Link

Document

dump an array of bytes to a String

Usage

From source file:com.villemos.ispace.aperture.enricher.MicrosoftPropertyReader.java

License:Open Source License

public void processPOIFSReaderEvent(final POIFSReaderEvent event) {
    PropertySet ps = null;/*w  w w .  ja v  a  2  s .c o  m*/
    try {
        ps = PropertySetFactory.create(event.getStream());
    } catch (NoPropertySetStreamException ex) {
        LOG.debug("No property set stream: \"" + event.getPath() + event.getName() + "\"");
        return;
    } catch (Exception ex) {
        LOG.error("Exception while processing microsoft property set " + ex);
    }

    /* Print the name of the property set stream: */
    LOG.debug("Property set stream \"" + event.getPath() + event.getName() + "\":");

    /* Print the list of sections: */
    List<Section> sections = ps.getSections();
    int nr = 0;
    for (Section sec : sections) {
        String s = HexDump.dump(sec.getFormatID().getBytes(), 0L, 0);
        s = s.substring(0, s.length() - 1);
        /* Print the number of properties in this section. */
        int propertyCount = sec.getPropertyCount();
        /* Print the properties: */
        Property[] properties = sec.getProperties();
        for (int i2 = 0; i2 < properties.length; i2++) {
            /* Print a single property: */
            Property p = properties[i2];
            long id = p.getID();
            long type = p.getType();
            Object value = p.getValue();

            String propertyName = sec.getPIDString(id);

            if (msProperties.containsKey(propertyName) == false) {
                String valueStr = value.toString();
                if (valueStr.equals("") == false) {
                    msProperties.put(propertyName, valueStr);
                }
            }
        }
    }
}

From source file:poi.hpsf.examples.ReadCustomPropertySets.java

License:Apache License

static String hex(final byte[] bytes) {
    return HexDump.dump(bytes, 0L, 0);
}