本文整理了Java中java.io.BufferedReader.reset()
方法的一些代码示例,展示了BufferedReader.reset()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BufferedReader.reset()
方法的具体详情如下:
包路径:java.io.BufferedReader
类名称:BufferedReader
方法名:reset
[英]Resets this reader's position to the last mark() location. Invocations of read() and skip() will occur from this new location.
[中]将此读卡器的位置重置为最后一个标记()位置。将从此新位置调用read()和skip()。
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Resets the stream to the most recent mark.
*/
@Override
public void reset() throws IOException {
line = lineMark;
column = columnMark;
super.reset();
}
代码示例来源:origin: robovm/robovm
/**
* Resets this reader to the last marked location. It also resets the line
* count to what is was when this reader was marked. This implementation
* resets the source reader.
*
* @throws IOException
* if this reader is already closed, no mark has been set or the
* mark is no longer valid because more than {@code readlimit}
* bytes have been read since setting the mark.
* @see #mark(int)
* @see #markSupported()
*/
@Override
public void reset() throws IOException {
synchronized (lock) {
super.reset();
lineNumber = markedLineNumber;
lastWasCR = markedLastWasCR;
}
}
代码示例来源:origin: libgdx/libgdx
public void load (BufferedReader reader) throws IOException {
super.load(reader);
// For backwards compatibility, independent property may not be defined
reader.mark(100);
String line = reader.readLine();
if (line == null) throw new IOException("Missing value: " + "independent");
if (line.contains("independent"))
independent = Boolean.parseBoolean(readString(line));
else
reader.reset();
}
代码示例来源:origin: libgdx/libgdx
public void load (BufferedReader reader) throws IOException {
super.load(reader);
// For backwards compatibility, independent property may not be defined
reader.mark(100);
String line = reader.readLine();
if (line == null) throw new IOException("Missing value: " + "independent");
if (line.contains("independent"))
independent = Boolean.parseBoolean(readString(line));
else
reader.reset();
}
代码示例来源:origin: marytts/marytts
/**
* Whether or not any more data can be read from this data source.
*
* @return true if another call to getData() will return data, false otherwise.
*/
public boolean hasMoreData() {
int c = -1;
try {
reader.mark(10);
c = reader.read();
reader.reset();
} catch (IOException ioe) {
ioe.printStackTrace();
}
return c != -1;
}
代码示例来源:origin: stanfordnlp/CoreNLP
public static List<SemgrexPattern> compileStream(InputStream is, Env env) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
reader.mark(MAX_STREAM_SIZE);
Map<String, String> macros = preprocess(reader);
reader.reset();
return parse(reader, macros, env);
}
代码示例来源:origin: marytts/marytts
/**
* Whether or not any more data can be read from this data source.
*
* @return true if another call to getData() will return data, false otherwise.
*/
public boolean hasMoreData() {
int c = -1;
try {
reader.mark(10);
c = reader.read();
reader.reset();
} catch (IOException ioe) {
ioe.printStackTrace();
}
return c != -1;
}
代码示例来源:origin: kiegroup/optaplanner
public boolean readOptionalConstantLine(String constantRegex) throws IOException {
bufferedReader.mark(1024);
boolean valid = true;
String line = bufferedReader.readLine();
if (line == null) {
valid = false;
} else {
String value = line.trim();
if (!value.matches(constantRegex)) {
valid = false;
}
}
if (!valid) {
bufferedReader.reset();
}
return valid;
}
代码示例来源:origin: Rajawali/Rajawali
/**
* Determine if a given BufferedReader appears to be in ASCII format.
*
* @param buffer
* @return
* @throws IOException
*/
public static final boolean isASCII(BufferedReader buffer) throws IOException {
final char[] readAhead = new char[300];
buffer.mark(readAhead.length);
buffer.read(readAhead, 0, readAhead.length);
buffer.reset();
final String readAheadString = new String(readAhead);
// If the following text is present, then this is likely an ascii file
return readAheadString.contains("facet normal") && readAheadString.contains("outer loop");
// Likely a binary file
}
代码示例来源:origin: apache/geode
/** create a stack with the given initial lines, reading the rest from the Reader */
ThreadStack(String firstLine, String secondLine, String thirdLine, BufferedReader reader)
throws IOException {
lines.add(firstLine);
lines.add(secondLine);
runnable = secondLine.contains("RUNNABLE");
lines.add(thirdLine);
String line = null;
do {
reader.mark(100000);
line = reader.readLine();
if (line == null || line.trim().length() == 0) {
break;
}
if (line.startsWith("\"")) {
reader.reset();
break;
}
lines.add(line);
} while (true);
}
代码示例来源:origin: embulk/embulk
private void skipBom() {
boolean skip = false;
try {
if (charset.equals(UTF_8)) {
reader.mark(3);
int firstChar = reader.read();
if (firstChar == 0xFEFF) {
// skip BOM bytes
skip = true;
}
}
} catch (IOException ex) {
// Passing through intentionally.
} finally {
if (skip) {
// firstChar is skipped
} else {
// rollback to the marked position
try {
reader.reset();
} catch (IOException ex) {
// unexpected
throw new RuntimeException(ex);
}
}
}
}
代码示例来源:origin: kiegroup/optaplanner
public String readOptionalStringValue(String prefixRegex, String suffixRegex, String defaultValue) throws IOException {
bufferedReader.mark(1024);
boolean valid = true;
String value = bufferedReader.readLine();
if (value == null) {
valid = false;
} else {
value = value.trim();
if (value.matches("^" + prefixRegex + ".*")) {
value = value.replaceAll("^" + prefixRegex + "(.*)", "$1");
} else {
valid = false;
}
if (value.matches(".*" + suffixRegex + "$")) {
value = value.replaceAll("(.*)" + suffixRegex + "$", "$1");
} else {
valid = false;
}
}
if (!valid) {
bufferedReader.reset();
return defaultValue;
}
value = value.trim();
return value;
}
代码示例来源:origin: geoserver/geoserver
input.reset();
代码示例来源:origin: com.h2database/h2
reader.reset();
代码示例来源:origin: lealone/Lealone
reader.reset();
代码示例来源:origin: geoserver/geoserver
reader.reset();
代码示例来源:origin: com.h2database/h2
return ValueLobDb.createSmallLob(Value.CLOB, small, len);
reader.reset();
return new ValueLobDb(handler, reader, remaining);
} catch (IOException e) {
代码示例来源:origin: lealone/Lealone
return ValueLob.createSmallLob(type, utf8);
b.reset();
reader = b;
代码示例来源:origin: geoserver/geoserver
input.reset();
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testMarkResetWithLineEnding() throws Exception {
SimpleBinaryBufferedReaderFactory factory = new SimpleBinaryBufferedReaderFactory();
factory.setLineEnding("||");
@SuppressWarnings("resource")
BufferedReader reader = factory.create(new ByteArrayResource("a||b||c".getBytes()), "UTF-8");
assertEquals("a", reader.readLine());
reader.mark(1024);
assertEquals("b", reader.readLine());
reader.reset();
assertEquals("b", reader.readLine());
assertEquals("c", reader.readLine());
assertEquals(null, reader.readLine());
}
内容来源于网络,如有侵权,请联系作者删除!