Class cStringIO.StringIO

All Implemented Interfaces:
Serializable, Iterable<Object>, Traverseproc
Enclosing class:
cStringIO

public static class cStringIO.StringIO extends PyIterator
The StringIO object
See Also:
  • Field Details

  • Constructor Details

    • StringIO

      public StringIO()
    • StringIO

      public StringIO(CharSequence buffer)
    • StringIO

      public StringIO(PyArray array)
  • Method Details

    • __setattr__

      public void __setattr__(String name, PyObject value)
      Description copied from class: PyObject
      A variant of the __setattr__ method which accepts a String as the key. This String must be interned.
      Overrides:
      __setattr__ in class PyObject
      Parameters:
      name - the name whose value will be set - must be an interned string .
      value - the value to set this name to
      See Also:
    • __iternext__

      public PyObject __iternext__()
      Description copied from class: PyObject
      Return the next element of the sequence that this is an iterator for. Returns null when the end of the sequence is reached.
      Specified by:
      __iternext__ in class PyIterator
    • close

      public void close()
      Free the memory buffer.
    • isatty

      public boolean isatty()
      Return false.
      Returns:
      false.
    • seek

      public void seek(long pos)
      Position the file pointer to the absolute position.
      Parameters:
      pos - the position in the file.
    • seek

      public void seek(long pos, int mode)
      Position the file pointer to the position in the .
      Parameters:
      pos - the position in the file.
      mode - 0=from the start, 1=relative, 2=from the end.
    • reset

      public void reset()
      Reset the file position to the beginning of the file.
    • tell

      public int tell()
      Return the file position.
      Returns:
      the position in the file.
    • read

      public PyString read()
      Read all data until EOF is reached. An empty string is returned when EOF is encountered immediately.
      Returns:
      A string containing the data.
    • read

      public PyString read(long size)
      Read at most size bytes from the file (less if the read hits EOF). If the size argument is negative, read all data until EOF is reached. An empty string is returned when EOF is encountered immediately.
      Parameters:
      size - the number of characters to read.
      Returns:
      A string containing the data read.
    • readline

      public PyString readline()
      Read one entire line from the file. A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line). An empty string is returned when EOF is hit immediately.
      Returns:
      data from the file up to and including the newline.
    • readline

      public PyString readline(long size)
      Read one entire line from the file. A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line). If the size argument is non-negative, it is a maximum byte count (including the trailing newline) and an incomplete line may be returned.
      Returns:
      data from the file up to and including the newline.
    • readlineNoNl

      public PyString readlineNoNl()
      Read and return a line without the trailing newline. Usind by cPickle as an optimization.
    • readlines

      public PyObject readlines()
      Read until EOF using readline() and return a list containing the lines thus read.
      Returns:
      a list of the lines.
    • readlines

      public PyObject readlines(long sizehint)
      Read until EOF using readline() and return a list containing the lines thus read.
      Returns:
      a list of the lines.
    • truncate

      public void truncate()
      truncate the file at the current position.
    • truncate

      public void truncate(long pos)
      truncate the file at the position pos.
    • write

      public void write(PyObject obj)
      Write a string to the file.
      Parameters:
      obj - The data to write.
    • write

      public void write(String s)
    • writeChar

      public void writeChar(char ch)
      Write a char to the file. Used by cPickle as an optimization.
      Parameters:
      ch - The data to write.
    • writelines

      public void writelines(PyObject lines)
      Write a list of strings to the file.
    • flush

      public void flush()
      Flush the internal buffer. Does nothing.
    • getvalue

      public PyString getvalue()
      Retrieve the entire contents of the ``file'' at any time before the StringIO object's close() method is called.
      Returns:
      the contents of the StringIO.