Package org.ujmp.core.util.io
Class SeekableLineInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.ujmp.core.util.io.SeekableLineInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class SeekableLineInputStream extends java.io.InputStream
This stream searches all line end characters (hex 0A) in a file. For Linux line splitting is OK, for Windows the character hex 0D has to be eliminated with String.trim()
-
-
Field Summary
Fields Modifier and Type Field Description private int
bufferSize
private long[]
countsTotal
private long[]
diffSum
private BufferedRandomAccessFile
in
private java.util.List<java.lang.Long>
lineEnds
private static long
MAXLINECOUNT
private long
maxLineLength
-
Constructor Summary
Constructors Constructor Description SeekableLineInputStream(java.io.File file)
SeekableLineInputStream(java.lang.String file)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
int
getLineCount()
long
getMaxLineLength()
java.lang.String
getMostProbableDelimiter()
int
read()
java.lang.String
readLine(int lineNumber)
-
-
-
Field Detail
-
MAXLINECOUNT
private static final long MAXLINECOUNT
- See Also:
- Constant Field Values
-
countsTotal
private final long[] countsTotal
-
diffSum
private final long[] diffSum
-
bufferSize
private int bufferSize
-
in
private BufferedRandomAccessFile in
-
lineEnds
private final java.util.List<java.lang.Long> lineEnds
-
maxLineLength
private long maxLineLength
-
-
Method Detail
-
getMaxLineLength
public long getMaxLineLength()
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
getLineCount
public int getLineCount()
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
getMostProbableDelimiter
public java.lang.String getMostProbableDelimiter()
-
readLine
public java.lang.String readLine(int lineNumber) throws java.io.IOException
- Throws:
java.io.IOException
-
-