/*
Like 'readFullyTo', but only reads the header-part.
Starts from the beginning each time it is called.
10264
public void readHeaderTo(OutputStream os) throws IOException {
        position = 0;
        byte[] buf = new byte[(int)responseBodyStart];
        int c = read(buf,0,buf.length);
        if(c != -1) {
            os.write(buf,0,c);
        }
    }
889677
def read_prologue(self):
        """"""
        with open(self.filename, "rb") as fp_:
            fp_.seek(self.mda['total_header_length'])
            data = np.fromfile(fp_, dtype=prologue, count=1)[0]

            self.prologue.update(recarray2dict(data))

        self.process_prologue()
919142
def read_header(self):
        """"""
        format = '!HHHHHH'
        length = struct.calcsize(format)
        info = struct.unpack(format,
                self.data[self.offset:self.offset + length])
        self.offset += length

        self.id = info[0]
        self.flags = info[1]
        self.num_questions = info[2]
        self.num_answers = info[3]
        self.num_authorities = info[4]
        self.num_additionals = info[5]
812463
public synchronized void setReadOnly()
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "setReadOnly");

      // And actually mark the real buffers as read-only too
      for (int x = 0; x < dataList.size(); x++)
      {
         WsByteBuffer buff = dataList.get(x);
         buff.setReadOnly(true);
      }

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "setReadOnly");
   }
1057666
private void startLiteral(int position) throws MalformedUriTemplateException
    {

        if (startedTemplate)
        {
            if (!literalCaptureOn)
            {
                //throw new IllegalStateException("Literal capture already started at character "+template[position]);
                literalCaptureOn = true;
                startPosition = position;
            }
        }
        else
        {
            throw new IllegalStateException("Cannot start a literal without beginning the template");
        }
    }
454290
def read(cls, f):
    """"""
    url = None

    line = f.readline()
    if not line:
      # EOF
      return None
    while not line.startswith(cls.LENGTH_HEADER):
      if line.startswith(cls.URI_HEADER):
        url = line[len(cls.URI_HEADER):].strip()
      line = f.readline()

    # Consume empty separator
    f.readline()

    # Read content
    length = int(line.split(':')[1])

    return cls(url, length)
1032386
public ReadStream openRead()
    throws IOException
  {
    if (_isDone)
      return null;
    else if (_readStream == null)
      _readStream = new ReadStream(this);
    else if (!_isPartDone) {
      int len;
      while ((len = read(_dummyBuffer, 0, _dummyBuffer.length)) >= 0) {
      }

      if (_isDone)
        return null;
    }

    _readStream.init(this);

    _isPartDone = false;

    if (scanHeaders()) {
      String contentType = (String) getAttribute("content-type");

      String charset = getAttributePart(contentType, "charset");

      // FIXME: 2016-05-14 
/*
      if (charset != null)
        _readStream.setEncoding(charset);
      else if (_defaultEncoding != null)
        _readStream.setEncoding(_defaultEncoding);
*/

      return _readStream;
    }
    else {
      _isDone = true;
      _readStream.close();
      return null;
    }
  }
836666
private SynchroTable readTableHeader(byte[] header)
   {
      SynchroTable result = null;
      String tableName = DatatypeConverter.getSimpleString(header, 0);
      if (!tableName.isEmpty())
      {
         int offset = DatatypeConverter.getInt(header, 40);
         result = new SynchroTable(tableName, offset);
      }
      return result;
   }
1204299
def loadtoc(self):
        
        self.lib.seek(self.start + self.TOCPOS)
        (offset,) = struct.unpack('!i', self.lib.read(4))
        self.lib.seek(self.start + offset)
        self.toc = marshal.load(self.lib)
545742
def read_header(filename):
    '''  '''
    header = {}
    in_header = False
    data = nl.universal_read(filename)
    lines = [x.strip() for x in data.split('\n')]
    for line in lines:
        if line=="*** Header Start ***":
            in_header=True
            continue
        if line=="*** Header End ***":
            return header
        fields = line.split(": ")
        if len(fields)==2:
            header[fields[0]] = fields[1]
1078439
def _ReadPartial(self, length):
    """"""
    chunk = self.offset // self.chunksize
    chunk_offset = self.offset % self.chunksize

    # If we're past the end of the file, we don't have a chunk to read from, so
    # we can't read anymore. We return the empty string here so we can read off
    # the end of a file without raising, and get as much data as is there.
    if chunk > self.last_chunk:
      return ""

    available_to_read = min(length, self.chunksize - chunk_offset)

    fd = self._GetChunkForReading(chunk)

    fd.seek(chunk_offset)

    result = fd.read(available_to_read)
    self.offset += len(result)

    return result
340541
@Override
  public void readHeader(RandomAccessFile file) throws IOException {
    file.seek(0);
    if(file.readInt() != FILE_VERSION) {
      throw new RuntimeException("File " + file + " is not a PersistentPageFile or wrong version!");
    }

    this.pageSize = file.readInt();
  }
102332
private String readHeaderString(BufferedInputStream stream) throws IOException
   {
      int bufferSize = 100;
      stream.mark(bufferSize);
      byte[] buffer = new byte[bufferSize];
      stream.read(buffer);
      Charset charset = CharsetHelper.UTF8;
      String header = new String(buffer, charset);
      int prefixIndex = header.indexOf("PPX!!!!|");
      int suffixIndex = header.indexOf("|!!!!XPP");

      if (prefixIndex != 0 || suffixIndex == -1)
      {
         throw new IOException("File format not recognised");
      }

      int skip = suffixIndex + 9;
      stream.reset();
      stream.skip(skip);

      return header.substring(prefixIndex + 8, suffixIndex);
   }
394352
def parse_header(filename):
    '''
    '''
    with open(filename, 'rb') as fh:
        content = '\n'.join(fh.read().splitlines())

    content = sub('\t', ' ', content)
    content = strip_comments(content)

    # first get the functions
    content = split(func_pat_short, content)

    for i, s in enumerate(content):
        if i % 2 and content[i].strip():  # matched a prototype
            try:
                content[i] = parse_prototype(content[i])
            except Exception as e:
                traceback.print_exc()

    # now process structs
    res = []
    for i, item in enumerate(content):
        if not isinstance(item, str):  # if it's already a func etc. skip it
            res.append(item)
            continue

        items = split(struct_pat, item)
        j = 0
        while j < len(items):
            if not j % 5:
                res.append(items[j])
                j += 1
            else:
                if items[j].strip() == 'enum':
                    res.append(parse_enum(*items[j + 1: j + 4]))
                else:
                    res.append(parse_struct(*items[j + 1: j + 4]))
                j += 4

    # now do remaining simple typedefs
    content = res
    res = []
    for i, item in enumerate(content):
        if not isinstance(item, str):  # if it's already processed skip it
            res.append(item)
            continue

        items = split(typedef_pat, item)
        for j, item in enumerate(items):
            res.append(TypeDef(item.strip()) if j % 2 else item)

    content = [c for c in res if not isinstance(c, str) or c.strip()]
    return content
1018001
private boolean readHeader() {
    boolean correct = true;
    ByteOrder byteOrder = ByteOrder.LITTLE_ENDIAN;
    int c1 = 0;
    int c2 = 0;
    try {
      c1 = data.readByte().toInt();
      c2 = data.readByte().toInt();
    } catch (Exception ex) {
      validation.addErrorLoc("Header IO Exception", "Header");
    }

    // read the first two bytes, in order to know the byte ordering
    if (c1 == 'I' && c2 == 'I') {
      byteOrder = ByteOrder.LITTLE_ENDIAN;
    } else if (c1 == 'M' && c2 == 'M') {
      byteOrder = ByteOrder.BIG_ENDIAN;
    }
    else if (byteOrderErrorTolerance > 0 && c1 == 'i' && c2 == 'i') {
      validation.addWarning("Byte Order in lower case", "" + c1 + c2, "Header");
      byteOrder = ByteOrder.LITTLE_ENDIAN;
    } else if (byteOrderErrorTolerance > 0 && c1 == 'm' && c2 == 'm') {
      validation.addWarning("Byte Order in lower case", "" + c1 + c2, "Header");
      byteOrder = ByteOrder.BIG_ENDIAN;
    } else if (byteOrderErrorTolerance > 1) {
      validation.addWarning("Non-sense Byte Order. Trying Little Endian.", "" + c1 + c2, "Header");
      byteOrder = ByteOrder.LITTLE_ENDIAN;
    } else {
      validation.addErrorLoc("Invalid Byte Order " + c1 + c2, "Header");
      correct = false;
    }
    if (correct) {
      tiffModel.setByteOrder(byteOrder);
      data.setByteOrder(byteOrder);

      try {
        // read magic number
        int magic = data.readShort().toInt();
        tiffModel.setMagicNumber(magic);
      } catch (Exception ex) {
        validation.addErrorLoc("Magic number parsing error", "Header");
        correct = false;
      }
    }
    return correct;
  }
1077739
protected long readReservedHeaders() throws IOException {
    long startcode = in.readStartCode();

    while (Startcode.isPossibleStartcode(startcode) && isKnownStartcode(startcode)) {
      new Packet().read(in, startcode); // Discard unknown packet
      startcode = in.readStartCode();
    }
    return startcode;
  }
959421
@Override
  public void readFully(byte[] b, int off, int len) throws IOException {
    while (len > 0) {
      int read = inner.read(b, off, len);
      if (read <= 0) {
        throw new EOFException();
      }
      off += read;
      len -= read;
    }
  }