本文整理汇总了Java中it.unimi.dsi.fastutil.io.FastBufferedInputStream.LineTerminator类的典型用法代码示例。如果您正苦于以下问题:Java LineTerminator类的具体用法?Java LineTerminator怎么用?Java LineTerminator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LineTerminator类属于it.unimi.dsi.fastutil.io.FastBufferedInputStream包,在下文中一共展示了LineTerminator类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FileLinesList
import it.unimi.dsi.fastutil.io.FastBufferedInputStream.LineTerminator; //导入依赖的package包/类
/** Creates a file-lines collection for the specified filename with the specified encoding, buffer size and terminator set.
*
* @param filename a filename.
* @param encoding an encoding.
* @param bufferSize the buffer size for {@link FastBufferedInputStream}.
* @param terminators a set of line terminators.
*/
public FileLinesList(final CharSequence filename, final String encoding, final int bufferSize, final EnumSet<FastBufferedInputStream.LineTerminator> terminators) throws IOException {
this.bufferSize = bufferSize;
this.terminators = terminators;
this.filename = filename.toString();
inputStream = new FastBufferedInputStream(new FileInputStream(this.filename), bufferSize);
decoder = (charset = Charset.forName(encoding)).newDecoder();
byte[] array = new byte[16];
int count = 0, start, len;
for(;;) {
start = 0;
while((len = inputStream.readLine(array, start, array.length - start, terminators)) == array.length - start) {
start += len;
array = ByteArrays.grow(array, array.length + 1);
};
if (len != -1) count++;
else break;
}
size = count;
byteBuffer = ByteBuffer.wrap(array);
charBuffer = CharBuffer.wrap(new char[array.length]);
inputStream.position(0);
borders = new EliasFanoMonotoneLongBigList(count, inputStream.length(), new LongIterator() {
long pos = 0;
byte[] buffer = byteBuffer.array();
@Override
public boolean hasNext() {
return pos < size;
}
@Override
public long nextLong() {
if (! hasNext()) throw new NoSuchElementException();
pos++;
try {
final long result = inputStream.position();
inputStream.readLine(buffer, terminators);
return result;
}
catch (final IOException e) {
throw new RuntimeException(e);
}
}
});
}
示例2: FileLinesBigList
import it.unimi.dsi.fastutil.io.FastBufferedInputStream.LineTerminator; //导入依赖的package包/类
/** Creates a file-lines collection for the specified filename with the specified encoding, buffer size and terminator set.
*
* @param filename a filename.
* @param encoding an encoding.
* @param bufferSize the buffer size for {@link FastBufferedInputStream}.
* @param terminators a set of line terminators.
*/
public FileLinesBigList(final CharSequence filename, final String encoding, final int bufferSize, final EnumSet<FastBufferedInputStream.LineTerminator> terminators) throws IOException {
this.bufferSize = bufferSize;
this.terminators = terminators;
this.filename = filename.toString();
inputStream = new FastBufferedInputStream(new FileInputStream(this.filename), bufferSize);
decoder = (charset = Charset.forName(encoding)).newDecoder();
byte[] array = new byte[16];
long count = 0;
int start, len;
for(;;) {
start = 0;
while((len = inputStream.readLine(array, start, array.length - start, terminators)) == array.length - start) {
start += len;
array = ByteArrays.grow(array, array.length + 1);
};
if (len != -1) count++;
else break;
}
size = count;
byteBuffer = ByteBuffer.wrap(array);
charBuffer = CharBuffer.wrap(new char[array.length]);
inputStream.position(0);
borders = new EliasFanoMonotoneLongBigList(count, inputStream.length(), new LongIterator() {
long pos = 0;
byte[] buffer = byteBuffer.array();
@Override
public boolean hasNext() {
return pos < size;
}
@Override
public long nextLong() {
if (! hasNext()) throw new NoSuchElementException();
pos++;
try {
final long result = inputStream.position();
inputStream.readLine(buffer, terminators);
return result;
}
catch (final IOException e) {
throw new RuntimeException(e);
}
}
});
}