public class CSVWire extends TextWire
Suitable for simple tabular data where each line represents a record and fields are delimited by commas. The first line is treated as a header row and defines the column names for subsequent rows. Nested or complex structures are not fully represented and may need to be flattened before writing to CSV.
TextWire.TextValueInWireIn.HeaderTypeWireOut.EndOfWireBINARY, lineStart, readContext, TYPE_STR, valueIn, writeContextsb, TYPE, valueOutbytes, classLookup, commentListener, DEFAULT_USE_PADDING, parent, use8bitMARSHALLABLE_IN_INTERN_SIZE| Constructor and Description |
|---|
CSVWire(@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes)
Creates a wire from the given bytes using UTF-8 encoding.
|
CSVWire(@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes,
boolean use8bit)
Creates a wire backed by the supplied bytes and parses the first line as
the header row.
|
| Modifier and Type | Method and Description |
|---|---|
void |
consumePadding()
Skips whitespace at the current position.
|
void |
consumePadding(int commas)
In CSV the
commas argument is ignored; this method delegates to
consumePadding(). |
void |
consumePaddingStart()
Consumes leading spaces and comment lines (prefixed with
#) so
the reader is positioned at the start of the header or first record. |
protected @NotNull TextWire.TextValueIn |
createValueIn()
Factory for
CSVValueIn instances used when reading values. |
protected @NotNull net.openhft.chronicle.wire.CSVWire.CSVValueOut |
createValueOut()
Factory for
CSVValueOut instances used when writing values. |
static @NotNull CSVWire |
from(@NotNull String text)
Creates a wire from the supplied text.
|
static @NotNull CSVWire |
fromFile(String name)
Builds a
CSVWire by loading the contents of the given file. |
@NotNull ValueIn |
read(@NotNull StringBuilder name)
Reads the next header name into
name and returns the
corresponding ValueIn for the value. |
@NotNull ValueIn |
read(@NotNull WireKey key)
Keys are not used when reading CSV so this simply returns
TextWire.valueIn. |
@NotNull Wire |
readComment(@NotNull StringBuilder s)
Clears
s as inline comments are not expected in CSV. |
@NotNull StringBuilder |
readField(@NotNull StringBuilder sb)
Reads the next column value into
sb assuming the wire is
positioned at the start of a field. |
acquireWritingDocument, asText, classLookup, classLookup, clear, consumeDocumentStart, consumeWhiteSpace, copyTo, defaultKeyClass, getEscapingEndEventName, getEscapingEndOfText, getEscapingQuotes, getStrictEscapingEndOfText, getValueIn, hasMetaDataPrefix, initReadContext, isBinary, load, methodReaderBuilder, methodWriter, methodWriterBuilder, newBooleanReference, newIntArrayReference, newIntReference, newLongArrayReference, newLongReference, parseUntil, parseUntil, parseWord, peekStringIgnoreCase, read, read2, read2, readCode, readEvent, readEventNumber, readingDocument, readingDocument, readingPeekYaml, readObject, reset, rollbackIfNotComplete, strict, strict, to8bitString, toString, toUtf8String, unescape, useBinaryDocuments, useSelfDescribingMessage, useTextDocuments, writingDocument, writingIsCompleteacquireStringBuilder, addPadding, addTimeStamps, addTimeStamps, append, append, appendU4, bytes, dropDefault, escape0, getValueOut, needsQuotes, trimFirstCurly, trimFirstCurly, write, write, write, writeComment, writeEndEvent, writeEvent, writeObject, writeStartEventbytesComment, commentListener, endOfWire, enterHeader, forceNotInsideHeader, generateTuples, generateTuples, headerNumber, headerNumber, headNumberCheck, isInsideHeader, notCompleteIsNotPresent, notCompleteIsNotPresent, objectInput, objectOutput, parent, parent, pauser, pauser, readAndSetLength, readDataHeader, readFirstHeader, readFirstHeader, readMetaDataHeader, updateFirstHeader, updateFirstHeader, updateHeader, usePadding, usePadding, writeEndOfWire, writeFirstHeaderclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitnewYamlWireOnHeapendEvent, hasMore, hintReadInputOrder, isEmpty, isEndEvent, isNotEmptyAfterPadding, rawReadData, read, readAlignTo, readAllAsMap, readDataHeader, readDocument, readDocument, readEventName, startEventmethodReader, readBytes, readBytes, readDocument, readMap, readText, readTextpadToCacheAlign, writeAlignTo, writeAllAsMap, writeDocument, writeEventId, writeEventId, writeEventName, writeEventName, writeNotCompleteDocument, writingDocumentnewTwoLongReferencebuilder, methodWriterBuilder, recordHistory, writeBytes, writeDocument, writeDocument, writeMap, writeMessage, writeMessage, writeTextpublic CSVWire(@NotNull
@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes,
boolean use8bit)
bytes - underlying bytes containing CSV textuse8bit - true to read 8-bit characters, otherwise UTF-8public CSVWire(@NotNull
@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes)
bytes - underlying CSV data@NotNull public static @NotNull CSVWire fromFile(String name) throws IOException
CSVWire by loading the contents of the given file.
Uses 8-bit parsing.name - path of the CSV fileIOException - if the file cannot be read@NotNull public static @NotNull CSVWire from(@NotNull @NotNull String text)
text - CSV data in string form@NotNull protected @NotNull net.openhft.chronicle.wire.CSVWire.CSVValueOut createValueOut()
CSVValueOut instances used when writing values.createValueOut in class YamlWireOut<TextWire>@NotNull protected @NotNull TextWire.TextValueIn createValueIn()
CSVValueIn instances used when reading values.createValueIn in class TextWire@NotNull public @NotNull StringBuilder readField(@NotNull @NotNull StringBuilder sb)
sb assuming the wire is
positioned at the start of a field.public void consumePaddingStart()
#) so
the reader is positioned at the start of the header or first record.public void consumePadding()
consumePadding in interface WireInconsumePadding in class TextWirepublic void consumePadding(int commas)
commas argument is ignored; this method delegates to
consumePadding().consumePadding in class TextWirecommas - The number of comma characters to consume. Once this count is reached, the method will return.@NotNull public @NotNull ValueIn read(@NotNull @NotNull WireKey key)
TextWire.valueIn.@NotNull public @NotNull ValueIn read(@NotNull @NotNull StringBuilder name)
name and returns the
corresponding ValueIn for the value.@NotNull public @NotNull Wire readComment(@NotNull @NotNull StringBuilder s)
s as inline comments are not expected in CSV.readComment in interface WireInreadComment in class TextWires - StringBuilder to which the comment will be appended.Copyright © 2026 Chronicle Software Ltd. All rights reserved.