Class PyFile

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    PyFileDerived

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

      • exposed_base

        public static final java.lang.Class exposed_base
      • name

        public java.lang.String name
      • mode

        public java.lang.String mode
      • softspace

        public boolean softspace
      • closed

        public boolean closed
    • Constructor Detail

      • PyFile

        public PyFile()
      • PyFile

        public PyFile​(PyType subType)
      • PyFile

        public PyFile​(org.python.core.PyFile.FileWrapper file,
                      java.lang.String name,
                      java.lang.String mode)
      • PyFile

        public PyFile​(java.io.InputStream istream,
                      java.io.OutputStream ostream,
                      java.lang.String name,
                      java.lang.String mode)
      • PyFile

        public PyFile​(java.io.InputStream istream,
                      java.io.OutputStream ostream,
                      java.lang.String name)
      • PyFile

        public PyFile​(java.io.InputStream istream,
                      java.io.OutputStream ostream)
      • PyFile

        public PyFile​(java.io.InputStream istream,
                      java.lang.String name,
                      java.lang.String mode)
      • PyFile

        public PyFile​(java.io.InputStream istream,
                      java.lang.String name)
      • PyFile

        public PyFile​(java.io.InputStream istream)
      • PyFile

        public PyFile​(java.io.OutputStream ostream,
                      java.lang.String name,
                      java.lang.String mode)
      • PyFile

        public PyFile​(java.io.OutputStream ostream,
                      java.lang.String name)
      • PyFile

        public PyFile​(java.io.OutputStream ostream)
      • PyFile

        public PyFile​(java.io.Writer ostream,
                      java.lang.String name,
                      java.lang.String mode)
      • PyFile

        public PyFile​(java.io.Writer ostream,
                      java.lang.String name)
      • PyFile

        public PyFile​(java.io.Writer ostream)
      • PyFile

        public PyFile​(java.io.RandomAccessFile file,
                      java.lang.String name,
                      java.lang.String mode)
      • PyFile

        public PyFile​(java.io.RandomAccessFile file,
                      java.lang.String name)
      • PyFile

        public PyFile​(java.io.RandomAccessFile file)
      • PyFile

        public PyFile​(java.lang.String name,
                      java.lang.String mode,
                      int bufsize)
    • Method Detail

      • __setattr__

        public void __setattr__​(java.lang.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:
        PyObject.__setattr__(PyString, PyObject)
      • __tojava__

        public java.lang.Object __tojava__​(java.lang.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 java.lang.String read​(int n)
      • read

        public java.lang.String read()
      • readline

        public java.lang.String readline​(int max)
      • readline

        public java.lang.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
      • xreadlines

        public PyObject xreadlines()
      • write

        public void write​(java.lang.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)
      • toString

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

        public java.lang.String getMode()
      • getName

        public java.lang.String getName()
      • getClosed

        public boolean getClosed()