com.upokecenter.util.DataIO

com.upokecenter.util.DataIO

public final class DataIO extends Object

Convenience class that contains static methods for wrapping byte arrays and streams into byte readers and byte writers.

Methods

Method Details

ToReader

public static IReader ToReader(byte[] bytes)

Wraps a byte array into a byte reader. The reader will start at the beginning of the byte array.

In the.NET implementation, this method is implemented as an extension method to any byte array object and can be called as follows: bytes.ToByteReader(). If the object's class already has a ToByteReader method with the same parameters, that method takes precedence over this extension method.

Parameters:

Returns:

Throws:

ToReader

public static IReader ToReader(byte[] bytes, int offset, int length)

Wraps a portion of a byte array into a byte reader object.

In the.NET implementation, this method is implemented as an extension method to any byte array object and can be called as follows: bytes.ToByteReader(offset, length). If the object's class already has a ToByteReader method with the same parameters, that method takes precedence over this extension method.

Parameters:

Returns:

Throws:

ToReader

public static IReader ToReader(InputStream input)

Wraps an input stream into a reader object. If an IOException is thrown by the input stream, the reader object throws IllegalStateException instead.

In the.NET implementation, this method is implemented as an extension method to any object implementing InputStream and can be called as follows: input.ToByteReader(). If the object's class already has a ToByteReader method with the same parameters, that method takes precedence over this extension method.

Parameters:

Returns:

Throws:

ToByteReader

@Deprecated public static IByteReader ToByteReader(byte[] bytes, int offset, int length)

Wraps a portion of a byte array into a byte reader.

In the.NET implementation, this method is implemented as an extension method to any object implementing byte[] and can be called as follows: bytes.ToByteReader(offset, length). If the object's class already has a ToByteReader method with the same parameters, that method takes precedence over this extension method.

Parameters:

Returns:

Throws:

ToByteReader

@Deprecated public static IByteReader ToByteReader(InputStream input)

Wraps a data stream into a byte reader.

In the.NET implementation, this method is implemented as an extension method to any object implementing InputStream and can be called as follows: input.ToByteReader(). If the object's class already has a ToByteReader method with the same parameters, that method takes precedence over this extension method.

Parameters:

Returns:

Throws:

ToByteReader

@Deprecated public static IByteReader ToByteReader(byte[] bytes)

Wraps a byte array into a byte reader.

In the.NET implementation, this method is implemented as an extension method to any object implementing byte[] and can be called as follows: bytes.ToByteReader(). If the object's class already has a ToByteReader method with the same parameters, that method takes precedence over this extension method.

Parameters:

Returns:

Throws:

ToWriter

public static IWriter ToWriter(OutputStream output)

Wraps an output stream into a writer object. If an IOException is thrown by the input stream, the writer object throws IllegalStateException instead.

In the.NET implementation, this method is implemented as an extension method to any object implementing InputStream and can be called as follows: output.ToWriter(). If the object's class already has a ToWriter method with the same parameters, that method takes precedence over this extension method.

Parameters:

Returns:

Throws:

ToWriter

public static IWriter ToWriter(IByteWriter output)

Wraps a byte writer (one that only implements a ReadByte method) to a writer (one that also implements a three-parameter Read method.)

In the.NET implementation, this method is implemented as an extension method to any object implementing IByteWriter and can be called as follows: output.ToWriter(). If the object's class already has a ToWriter method with the same parameters, that method takes precedence over this extension method.

Parameters:

Returns:

Throws:

Back to Encoding start page.