List of usage examples for org.apache.poi.poifs.filesystem DocumentInputStream readByte
@Override
public byte readByte()
From source file:org.ddt.listener.ole.FileMoniker.java
License:Apache License
/** * Helper function that populates the fields of this moniker from the given stream * * @param inStream the stream to read from * @throws IOException/*from www .j a va 2 s. c om*/ * @ throws * BadOleStreamException */ private void populate(DocumentInputStream inStream) throws IOException, BadOleStreamException { cAnti = inStream.readShort(); ansiLength = inStream.readInt(); ansiPath = new byte[ansiLength - 1]; //don't get the last char (\0) if (inStream.read(ansiPath) != ansiLength - 1) { throw new BadOleStreamException("Couldn't read Path."); } inStream.skip(1); //skip the string terminating null char endServer = inStream.readShort(); versionNumber = inStream.readShort(); if (versionNumber != VERSION_NUMBER) { throw new BadOleStreamException("wrong version number: " + this.getVersionNumberHexString()); } inStream.skip(20); //skip the two reserved fields. should check that they are both 0. unicodePathSize = inStream.readInt(); //the rest of the fields only exist if unicodePathSize > 0 if (unicodePathSize <= 0) { return; } unicodePathBytes = inStream.readInt(); usKeyValue = inStream.readShort(); //should really make this a char array or a string. unicodePath = new byte[unicodePathBytes]; for (int i = 0; i < (unicodePathBytes); i++) { unicodePath[i] = inStream.readByte(); } }