Namespace Lucene.Net.Support.IO
Classes
BinaryReaderDataInput
BinaryWriterDataOutput
Buffer
A buffer is a list of elements of a specific primitive type.
A buffer can be described by the following properties:
- Capacity: The number of elements a buffer can hold. Capacity may not be negative and never changes.
- Position: A cursor of this buffer. Elements are read or written at the position if you do not specify an index explicitly. Position may not be negative and not greater than the limit.
-
Limit:
Controls the scope of accessible elements. You can only read or
write elements from index zero to
limit - 1
. Accessing elements out of the scope will cause an exception. Limit may not be negative and not greater than capacity. - Mark: Used to remember the current position, so that you can reset the position later. Mark may not be negative and no greater than position.
- A buffer can be read-only or read-write. Trying to modify the elements of a read-only buffer will cause a ReadOnlyBufferException, while changing the position, limit and mark of a read-only buffer is OK.
- A buffer can be direct or indirect. A direct buffer will try its best to take advantage of native memory APIs and it may not stay in the heap, thus it is not affected by garbage collection.
Buffers are not thread-safe. If concurrent access to a buffer instance is required, then the callers are responsible to take care of the synchronization issues.
BufferOverflowException
BufferUnderflowException
ByteArrayOutputStream
ByteBuffer
A buffer for bytes.
A byte buffer can be created in either one of the following ways:
- Allocate(Int32) a new byte array and create a buffer based on it
- AllocateDirect(Int32) a memory block and create a direct buffer based on it
- Wrap(Byte[]) an existing byte array to create a new buffer
ByteOrder
Defines byte order constants.
DataInputStream
Java's DataInputStream is similar to .NET's BinaryReader. However, it reads using a modified UTF-8 format that cannot be read using BinaryReader. This is a port of DataInputStream that is fully compatible with Java's DataOutputStream.
Usage Note: Always favor BinaryReader over DataInputStream unless you specifically need the modified UTF-8 format and/or the ReadUTF() or Lucene.Net.Support.IO.DataInputStream.DecodeUTF(System.Int32) method.
DataOutputStream
Java's DataOutputStream is similar to .NET's BinaryWriter. However, it writes in a modified UTF-8 format that cannot be read (or duplicated) using BinaryWriter. This is a port of DataOutputStream that is fully compatible with Java's DataInputStream.
Usage Note: Always favor BinaryWriter over DataOutputStream unless you specifically need the modified UTF-8 format and/or the WriteUTF(String) method.
FileStreamExtensions
FileSupport
Represents the methods to support some operations over files.
Int64Buffer
A buffer of longs.
A long buffer can be created in either of the following ways:
- Allocate(Int32) a new long array and create a buffer based on it
- Wrap(Int64[]) an existing long array to create a new buffer
InvalidMarkException
ReadOnlyBufferException
SafeTextWriterWrapper
Decorates a System.IO.TextWriter instance and makes no assumptions about whether System.IDisposable.Dispose() has been called on the inner instance or not. Acts like a circuit breaker - the first System.ObjectDisposedException caught turns it off and the rest of the calls are ignored after that point until Reset() is called.
The primary purpose is for using a System.IO.TextWriter instance within a non-disposable parent object. Since the creator of the System.IO.TextWriter ultimately is responsible for disposing it, our non-disposable object has no way of knowing whether it is safe to use the System.IO.TextWriter. Wraping the System.IO.TextWriter within a SafeTextWriterWrapper ensures the non-disposable object can continue to make calls to the System.IO.TextWriter without raising exceptions (it is presumed that the System.IO.TextWriter functionality is optional).
StreamExtensions
Extension methods that make a System.IO.Stream effectively into a binary serializer with no encoding. We simply convert types into bytes and write them without any concern whether surrogate pairs are respected, similar to what BinaryFormatter does. This makes it possible to serialize/deserialize raw character arrays and get the data back in the same order without any exceptions warning that the order is not valid and without the need for BinaryFormatter.
Byte order is little-endian (same as System.IO.BinaryReader and System.IO.BinaryWriter).
StreamTokenizer
Parses a stream into a set of defined tokens, one at a time. The different types of tokens that can be found are numbers, identifiers, quoted strings, and different comment styles. The class can be used for limited processing of source code of programming languages like Java, although it is nowhere near a full parser.
Interfaces
IDataInput
Equivalent to Java's DataInput interface
IDataOutput
Equivalent to Java's DataOutut interface