本文整理汇总了Java中java.io.StringReader.mark方法的典型用法代码示例。如果您正苦于以下问题:Java StringReader.mark方法的具体用法?Java StringReader.mark怎么用?Java StringReader.mark使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.StringReader
的用法示例。
在下文中一共展示了StringReader.mark方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: skipLws
import java.io.StringReader; //导入方法依赖的package包/类
private static int skipLws(StringReader input, boolean withReset)
throws IOException {
if (withReset) {
input.mark(1);
}
int c = input.read();
while (c == 32 || c == 9 || c == 10 || c == 13) {
if (withReset) {
input.mark(1);
}
c = input.read();
}
if (withReset) {
input.reset();
}
return c;
}
示例2: getTag
import java.io.StringReader; //导入方法依赖的package包/类
private String getTag(StringReader reader) throws IOException, TextParseException {
StringBuilder builder = new StringBuilder();
int c;
reader.mark(1);
while ((c = reader.read()) != '>' && !Character.isWhitespace(c)) {
if (c <= 0) {
throw new TextParseException("Unterminated tag");
}
reader.mark(1);
builder.append((char) c);
}
reader.reset();
return builder.toString();
}
示例3: skipLws
import java.io.StringReader; //导入方法依赖的package包/类
private static int skipLws(StringReader input, boolean withReset) throws IOException {
if (withReset) {
input.mark(1);
}
int c = input.read();
while (c == 32 || c == 9 || c == 10 || c == 13) {
if (withReset) {
input.mark(1);
}
c = input.read();
}
if (withReset) {
input.reset();
}
return c;
}
示例4: readString
import java.io.StringReader; //导入方法依赖的package包/类
public static String readString(StringReader rd) throws Exception {
// if there is an error in encoding, let the base functions throw an exception
CSList<Character> clist = new CSList<Character>();
int nextchar = -1;
boolean stop = false;
while (!stop)
{
if ((nextchar = rd.read()) == -1)
stop = true;
else if ((char)nextchar != '|')
clist.add((char)nextchar);
else
{
// ignore first | and check whether there is another | following
// if the next one is | again, then
rd.mark(1);
if (((nextchar = rd.read()) != -1) && ((char)nextchar == '|'))
{
// this was an escaped |, and so read it as such
clist.add((char)nextchar);
}
else
{
rd.reset(); //return the stolen character
stop = true;
}
}
}
return clist.toArray().toString();
}