Class PyFile

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
PyFileDerived

public class PyFile extends PyObject
A python file wrapper around a java stream, reader/writer or file.
See Also:
  • Field Details

    • exposed_name

      public static final String exposed_name
      See Also:
    • exposed_base

      public static final Class exposed_base
    • name

      public String name
    • mode

      public String mode
    • softspace

      public boolean softspace
    • closed

      public boolean closed
  • Constructor Details

  • Method Details

    • typeSetup

      public static void typeSetup(PyObject dict, PyType.Newstyle marker)
    • __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:
    • __tojava__

      public Object __tojava__(Class cls)
      Description copied from class: PyObject
      Equivalent to the Jython __tojava__ method. Tries to coerce this object to an instance of the requested Java class. Returns the special object Py.NoConversion if this PyObject can not be converted to the desired Java class.
      Overrides:
      __tojava__ in class PyObject
      Parameters:
      cls - the Class to convert this PyObject to.
    • read

      public String read(int n)
    • read

      public String read()
    • readline

      public String readline(int max)
    • readline

      public String readline()
    • readlines

      public PyObject readlines(int sizehint)
    • readlines

      public PyObject readlines()
    • __iter__

      public PyObject __iter__()
      Description copied from class: PyObject
      Return an iterator that is used to iterate the element of this sequence. From version 2.2, this method is the primary protocol for looping over sequences.

      If a PyObject subclass should support iteration based in the __finditem__() method, it must supply an implementation of __iter__() like this:

          public PyObject __iter__() {
              return new PySequenceIter(this);
          }
       
      When iterating over a python sequence from java code, it should be done with code like this:
          PyObject iter = seq.__iter__();
          for (PyObject item; (item = iter.__iternext__()) != null;)  {
              // Do somting with item
          }
       
      Overrides:
      __iter__ in class PyObject
    • __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.
      Overrides:
      __iternext__ in class PyObject
    • next

      public PyObject next()
    • xreadlines

      public PyObject xreadlines()
    • write

      public void write(String s)
    • writelines

      public void writelines(PyObject a)
    • tell

      public long tell()
    • seek

      public void seek(long pos, int how)
    • seek

      public void seek(long pos)
    • flush

      public void flush()
    • close

      public void close()
    • truncate

      public void truncate()
    • truncate

      public void truncate(long position)
    • fileno

      public PyObject fileno()
    • toString

      public String toString()
      Overrides:
      toString in class PyObject
    • getMode

      public String getMode()
    • getName

      public String getName()
    • getClosed

      public boolean getClosed()