Top Description Fields Constructors Methods
org.python.core.io

public Class TextIOWrapper

extends BinaryIOWrapper
Class Inheritance
Imports
java.nio.ByteBuffer, java.util.regex.Pattern

A Buffered text stream. This differs from py3k TextIOWrapper, which currently handles both text mode (py3k text mode is incompatible with Python 2.x's text mode) as well as universal mode.
Author
Philip Jenvey
See Also
UniversalIOWrapper

Field Summary

Modifier and TypeField and Description
private static final Pattern
LF_PATTERN

LF RE pattern, used for writes

private String
newline

The platform's Newline character

private boolean
newlineIsLF

Whether or not newline is \n

Constructor Summary

AccessConstructor and Description
public
TextIOWrapper(BufferedIOBase bufferedIO)

Contruct a TextIOWrapper wrapping the given BufferedIOBase.

Method Summary

Modifier and TypeMethod and Description
public String
read(int
the number of bytes to read
size
)

Overrides org.python.core.io.BinaryIOWrapper.read.

Read and return up to size bytes, contained in a String.

public String
public String
readline(int
the number of bytes to read
size
)

Overrides org.python.core.io.BinaryIOWrapper.readline.

Read until size, newline or EOF.

private int

Returns:

the number of chars written to the destination array
readLoop
(byte[]
the source byte array
src
,
int
starting position in the source array
srcPos
,
char[]
the destination char array
dest
,
int
starting position in the destination array
destPos
,
int
the number of array elements to be copied
length
)

Read and convert the src byte array into the dest char array.

public int
write(String
a String value
buf
)

Overrides org.python.core.io.BinaryIOWrapper.write.

Write the given String to the IO stream.

Field Detail

LF_PATTERNback to summary
private static final Pattern LF_PATTERN

LF RE pattern, used for writes

newlineback to summary
private String newline

The platform's Newline character

newlineIsLFback to summary
private boolean newlineIsLF

Whether or not newline is \n

Constructor Detail

TextIOWrapperback to summary
public TextIOWrapper(BufferedIOBase bufferedIO)

Contruct a TextIOWrapper wrapping the given BufferedIOBase.

Method Detail

readback to summary
public String read(int size)

Overrides org.python.core.io.BinaryIOWrapper.read.

Doc from org.python.core.io.TextIOBase.read.

Read and return up to size bytes, contained in a String. Returns an empty String on EOF

Parameters
size:int

the number of bytes to read

Returns:String

a String containing the bytes read

Annotations
@Override
readallback to summary
public String readall()

Overrides org.python.core.io.BinaryIOWrapper.readall.

Doc from org.python.core.io.TextIOBase.readall.

Read until EOF.

Returns:String

a String containing the bytes read

Annotations
@Override
readlineback to summary
public String readline(int size)

Overrides org.python.core.io.BinaryIOWrapper.readline.

Doc from org.python.core.io.TextIOBase.readline.

Read until size, newline or EOF. Returns an empty string if EOF is hit immediately.

Parameters
size:int

the number of bytes to read

Returns:String

a String containing the bytes read

Annotations
@Override
readLoopback to summary
private int readLoop(byte[] src, int srcPos, char[] dest, int destPos, int length)

Read and convert the src byte array into the dest char array. Converts CRLF to LF. src is assumed to be the end of the file; that is, when src ends with CR, no attempt is made to peek into the underlying file to detect a succeeding LF.

Parameters
src:byte[]

the source byte array

srcPos:int

starting position in the source array

dest:char[]

the destination char array

destPos:int

starting position in the destination array

length:int

the number of array elements to be copied

Returns:int

the number of chars written to the destination array

writeback to summary
public int write(String buf)

Overrides org.python.core.io.BinaryIOWrapper.write.

Doc from org.python.core.io.TextIOBase.write.

Write the given String to the IO stream. Returns the number of characters written.

Parameters
buf:String

a String value

Returns:int

the number of characters written as an int

Annotations
@Override