Package org.apache.poi.util

Examples of org.apache.poi.util.LittleEndianOutputStream


      throw new RuntimeException(e);
    }

    md5.update(_keyDigest);
    ByteArrayOutputStream baos = new ByteArrayOutputStream(4);
    new LittleEndianOutputStream(baos).writeInt(keyBlockNo);
    md5.update(baos.toByteArray());

    byte[] digest = md5.digest();
    return new RC4(digest);
  }
View Full Code Here


   */
  protected abstract int getDataSize();
  public byte[] serialize() {
    int size = getDataSize() + 4;
    ByteArrayOutputStream baos = new ByteArrayOutputStream(size);
    serialize(new LittleEndianOutputStream(baos));
    if (baos.size() != size) {
      throw new RuntimeException("write size mismatch");
    }
    return baos.toByteArray();
  }
View Full Code Here

    private void testReadWrite(byte[] data, String message) throws IOException
    {
        RecordInputStream is = TestcaseRecordInputStream.create(81, data);
        DConRefRecord d = new DConRefRecord(is);
        ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length);
        LittleEndianOutputStream o = new LittleEndianOutputStream(bos);
        d.serialize(o);
        o.flush();

        assertTrue(message, Arrays.equals(data,
                bos.toByteArray()));
    }
View Full Code Here

    public void testStore() throws IOException {
        CellRangeAddress ref = new CellRangeAddress(0, 0, 0, 0);

        byte[] recordBytes;
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        LittleEndianOutputStream out = new LittleEndianOutputStream(baos);
        try {
            // With nothing set
            ref.serialize(out);
            recordBytes = baos.toByteArray();
            assertEquals(recordBytes.length, data.length);
            for (int i = 0; i < data.length; i++) {
                assertEquals("At offset " + i, 0, recordBytes[i]);
            }

            // Now set the flags
            ref.setFirstRow((short) 2);
            ref.setLastRow((short) 4);
            ref.setFirstColumn((short) 0);
            ref.setLastColumn((short) 3);

            // Re-test
            baos.reset();
            ref.serialize(out);
            recordBytes = baos.toByteArray();

            assertEquals(recordBytes.length, data.length);
            for (int i = 0; i < data.length; i++) {
                assertEquals("At offset " + i, data[i], recordBytes[i]);
            }
        } finally {
            out.close();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.util.LittleEndianOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.