Examples of LittleEndianOutputStream


Examples of org.apache.poi.util.LittleEndianOutputStream

     */
    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

Examples of org.apache.poi.util.LittleEndianOutputStream

            // 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

Examples of org.apache.poi.util.LittleEndianOutputStream

            // 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

Examples of org.apache.poi.util.LittleEndianOutputStream

            // 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

Examples of org.apache.poi.util.LittleEndianOutputStream

   */
  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

Examples of org.apache.poi.util.LittleEndianOutputStream

        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

Examples of org.apache.poi.util.LittleEndianOutputStream

            // 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

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

Examples of org.apache.poi.util.LittleEndianOutputStream

   */
  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

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
TOP
Copyright © 2018 www.massapi.com. 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.