Package org.apache.poi.util

Examples of org.apache.poi.util.LittleEndianOutputStream


        LittleEndianInputStream in = new LittleEndianInputStream(new ByteArrayInputStream(data));

        LbsDataSubRecord.LbsDropData lbs = new LbsDataSubRecord.LbsDropData(in);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        lbs.serialize(new LittleEndianOutputStream(baos));

        assertTrue(Arrays.equals(data, baos.toByteArray()));
    }
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

       FormatRun fr = new FormatRun((short)4, (short)0x15c);
       assertEquals(4, fr.getCharacterPos());
       assertEquals(0x15c, fr.getFontIndex());
      
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       LittleEndianOutputStream out = new LittleEndianOutputStream(baos);
      
       fr.serialize(out);
      
       byte[] b = baos.toByteArray();
       assertEquals(4, b.length);
View Full Code Here

       assertEquals("", ext.getPhoneticText());
       assertEquals(0, ext.getPhRuns().length);
       assertEquals(10, ext.getDataSize()); // Excludes 4 byte header
      
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       LittleEndianOutputStream out = new LittleEndianOutputStream(baos);
       ContinuableRecordOutput cout = new ContinuableRecordOutput(out, 0xffff);
      
       ext.serialize(cout);
       cout.writeContinue();
      
View Full Code Here

     */
    public void writeOut(OutputStream out) throws IOException {
        // byte intbuf[] = new byte[LittleEndianConsts.INT_SIZE];
        // byte shortbuf[] = new byte[LittleEndianConsts.SHORT_SIZE];

        @SuppressWarnings("resource")
        LittleEndianOutputStream leosOut = new LittleEndianOutputStream(out);
       
        switch (mode) {
        case parsed: {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            LittleEndianOutputStream leos = new LittleEndianOutputStream(bos);
            // total size, will be determined later ..

            leos.writeShort(getFlags1());
            leos.write(getLabel().getBytes(ISO1));
            leos.write(0);
            leos.write(getFileName().getBytes(ISO1));
            leos.write(0);
            leos.writeShort(getFlags2());
            leos.writeShort(getUnknown1());
            leos.writeInt(getCommand().length() + 1);
            leos.write(getCommand().getBytes(ISO1));
            leos.write(0);
            leos.writeInt(getDataSize());
            leos.write(getDataBuffer());
            leos.writeShort(getFlags3());
            leos.close(); // satisfy compiler ...
           
            leosOut.writeInt(bos.size()); // total size
            bos.writeTo(out);
            break;
        }
View Full Code Here

            // TODO: any properties???
        }
   
        public void processPOIFSWriterEvent(POIFSWriterEvent event) {
            try {
                LittleEndianOutputStream leos = new LittleEndianOutputStream(event.getStream());

                // StreamSize (8 bytes): An unsigned integer that specifies the number of bytes used by data
                // encrypted within the EncryptedData field, not including the size of the StreamSize field.
                // Note that the actual size of the \EncryptedPackage stream (1) can be larger than this
                // value, depending on the block size of the chosen encryption algorithm
                leos.writeLong(countBytes);

                FileInputStream fis = new FileInputStream(fileOut);
                IOUtils.copy(fis, leos);
                fis.close();
                fileOut.delete();

                leos.close();
            } catch (IOException e) {
                throw new EncryptedDocumentException(e);
            }
        }
View Full Code Here

            // TODO: any properties???
        }
   
        public void processPOIFSWriterEvent(POIFSWriterEvent event) {
            try {
                LittleEndianOutputStream leos = new LittleEndianOutputStream(event.getStream());

                // StreamSize (8 bytes): An unsigned integer that specifies the number of bytes used by data
                // encrypted within the EncryptedData field, not including the size of the StreamSize field.
                // Note that the actual size of the \EncryptedPackage stream (1) can be larger than this
                // value, depending on the block size of the chosen encryption algorithm
                leos.writeLong(_pos);

                FileInputStream fis = new FileInputStream(fileOut);
                IOUtils.copy(fis, leos);
                fis.close();
                fileOut.delete();

                leos.close();
            } catch (IOException e) {
                throw new EncryptedDocumentException(e);
            }
        }
View Full Code Here

            // TODO: any properties???
        }
   
        public void processPOIFSWriterEvent(POIFSWriterEvent event) {
            try {
                LittleEndianOutputStream leos = new LittleEndianOutputStream(event.getStream());

                // StreamSize (8 bytes): An unsigned integer that specifies the number of bytes used by data
                // encrypted within the EncryptedData field, not including the size of the StreamSize field.
                // Note that the actual size of the \EncryptedPackage stream (1) can be larger than this
                // value, depending on the block size of the chosen encryption algorithm
                leos.writeLong(countBytes);

                FileInputStream fis = new FileInputStream(fileOut);
                IOUtils.copy(fis, leos);
                fis.close();
                fileOut.delete();

                leos.close();
            } catch (IOException e) {
                throw new EncryptedDocumentException(e);
            }
        }
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

        LittleEndianInputStream in = new LittleEndianInputStream(new ByteArrayInputStream(data));
        try {
            LbsDataSubRecord.LbsDropData lbs = new LbsDataSubRecord.LbsDropData(in);
   
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            LittleEndianOutputStream out = new LittleEndianOutputStream(baos);
            try {
                lbs.serialize(out);
       
                assertArrayEquals(data, baos.toByteArray());
            } finally {
                out.close();
            }
        } finally {
            in.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.