public class LineCounter extends Object implements Closeable
| Constructor and Description |
|---|
LineCounter(InputStream is,
int bufferSize)
构造
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
int |
getCount()
获取行数
|
LineCounter |
setLastLineSeparatorAsNewLine(boolean lastLineSeparatorAsNewLine)
设置是否将最后一行分隔符作为新行,Linux下要求最后一行必须带有换行符,不算一行,此处用户选择
|
public LineCounter(InputStream is, int bufferSize)
is - 输入流bufferSize - 缓存大小,小于1则使用默认的1024public LineCounter setLastLineSeparatorAsNewLine(boolean lastLineSeparatorAsNewLine)
lastLineSeparatorAsNewLine - 是否将最后一行分隔符作为新行public int getCount()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2025. All rights reserved.