Example usage for org.apache.poi.poifs.filesystem DocumentInputStream readFully

List of usage examples for org.apache.poi.poifs.filesystem DocumentInputStream readFully

Introduction

In this page you can find the example usage for org.apache.poi.poifs.filesystem DocumentInputStream readFully.

Prototype

@Override
    public void readFully(byte[] buf, int off, int len) 

Source Link

Usage

From source file:ReadOLE2Entry.java

License:Open Source License

public static double[] ReadDouble(DocumentEntry document) throws IOException {
    DocumentInputStream stream = new DocumentInputStream(document);
    int len = document.getSize();
    byte[] buf = new byte[len];
    double[] bufDbl = new double[len / 8];
    try {/*  ww  w .  j a va  2  s  .  c o m*/
        stream.readFully(buf, 0, len);
    } finally {
        stream.close();
    }
    ByteBuffer.wrap(buf).order(ByteOrder.LITTLE_ENDIAN).asDoubleBuffer().get(bufDbl);
    return bufDbl;
}

From source file:ReadOLE2Entry.java

License:Open Source License

public static int[] ReadInt(DocumentEntry document) throws IOException {
    DocumentInputStream stream = new DocumentInputStream(document);
    int len = document.getSize();
    byte[] buf = new byte[len];
    int[] bufInt = new int[len / 4];
    try {/*from   ww  w  .  j  av  a 2  s.c om*/
        stream.readFully(buf, 0, len);
    } finally {
        stream.close();
    }
    ByteBuffer.wrap(buf).order(ByteOrder.LITTLE_ENDIAN).asIntBuffer().get(bufInt);
    return bufInt;
}

From source file:ReadOLE2Entry.java

License:Open Source License

public static short[] ReadShort(DocumentEntry document) throws IOException {
    DocumentInputStream stream = new DocumentInputStream(document);
    int len = document.getSize();
    byte[] buf = new byte[len];
    short[] bufShort = new short[len / 2];
    try {//ww w.  j a  v  a 2  s  .  co  m
        stream.readFully(buf, 0, len);
    } finally {
        stream.close();
    }
    ByteBuffer.wrap(buf).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer().get(bufShort);
    return bufShort;
}

From source file:ReadOLE2Entry.java

License:Open Source License

public static byte[] ReadBytes(DocumentEntry document) throws IOException {
    DocumentInputStream stream = new DocumentInputStream(document);
    int len = document.getSize();
    byte[] buf = new byte[len];
    try {/* w  w  w.ja v  a 2 s.  c  o  m*/
        stream.readFully(buf, 0, len);
    } finally {
        stream.close();
    }
    return buf;
}

From source file:ReadOLE2Entry.java

License:Open Source License

public static String ReadString(DocumentEntry document) throws IOException {
    DocumentInputStream stream = new DocumentInputStream(document);
    int len = document.getSize();
    byte[] buf = new byte[len];
    try {/*from w w w . j  a va 2  s .c om*/
        stream.readFully(buf, 0, len);
    } finally {
        stream.close();
    }
    String str = new String(buf);
    return str;
}