本文整理匯總了Java中java.io.StreamTokenizer.nextToken方法的典型用法代碼示例。如果您正苦於以下問題:Java StreamTokenizer.nextToken方法的具體用法?Java StreamTokenizer.nextToken怎麽用?Java StreamTokenizer.nextToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.io.StreamTokenizer
的用法示例。
在下文中一共展示了StreamTokenizer.nextToken方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseBenchArgs
import java.io.StreamTokenizer; //導入方法依賴的package包/類
String[] parseBenchArgs(StreamTokenizer tokens)
throws IOException, ConfigFormatException
{
Vector vec = new Vector();
for (;;) {
switch (tokens.ttype) {
case StreamTokenizer.TT_EOF:
case StreamTokenizer.TT_EOL:
return (String[]) vec.toArray(new String[vec.size()]);
case StreamTokenizer.TT_WORD:
case '"':
vec.add(tokens.sval);
tokens.nextToken();
break;
default:
throw new ConfigFormatException("unrecognized arg token " +
"on line " + tokens.lineno());
}
}
}
示例2: parseBenchName
import java.io.StreamTokenizer; //導入方法依賴的package包/類
String parseBenchName(StreamTokenizer tokens)
throws IOException, ConfigFormatException
{
String name;
switch (tokens.ttype) {
case StreamTokenizer.TT_WORD:
case '"':
name = tokens.sval;
tokens.nextToken();
return name;
default:
throw new ConfigFormatException("missing benchmark name on " +
"line " + tokens.lineno());
}
}
示例3: loadCmdFile
import java.io.StreamTokenizer; //導入方法依賴的package包/類
private static void loadCmdFile(String name, List<String> args)
throws IOException
{
Reader r = new BufferedReader(new FileReader(name));
StreamTokenizer st = new StreamTokenizer(r);
st.resetSyntax();
st.wordChars(' ', 255);
st.whitespaceChars(0, ' ');
st.commentChar('#');
st.quoteChar('"');
st.quoteChar('\'');
while (st.nextToken() != StreamTokenizer.TT_EOF) {
args.add(st.sval);
}
r.close();
}
示例4: parseBenchWeight
import java.io.StreamTokenizer; //導入方法依賴的package包/類
float parseBenchWeight(StreamTokenizer tokens)
throws IOException, ConfigFormatException
{
float weight;
switch (tokens.ttype) {
case StreamTokenizer.TT_WORD:
case '"':
try {
weight = Float.parseFloat(tokens.sval);
} catch (NumberFormatException e) {
throw new ConfigFormatException("illegal weight value \"" +
tokens.sval + "\" on line " + tokens.lineno());
}
tokens.nextToken();
return weight;
default:
throw new ConfigFormatException("missing weight value on line "
+ tokens.lineno());
}
}
示例5: parseAppConfigurationEntry
import java.io.StreamTokenizer; //導入方法依賴的package包/類
private AppConfigurationEntry parseAppConfigurationEntry(StreamTokenizer tokenizer) throws IOException {
String loginModule = tokenizer.sval;
if (tokenizer.nextToken() == StreamTokenizer.TT_EOF)
throw new IllegalArgumentException("Login module control flag not specified in JAAS config");
LoginModuleControlFlag controlFlag = loginModuleControlFlag(tokenizer.sval);
Map<String, String> options = new HashMap<>();
while (tokenizer.nextToken() != StreamTokenizer.TT_EOF && tokenizer.ttype != ';') {
String key = tokenizer.sval;
if (tokenizer.nextToken() != '=' || tokenizer.nextToken() == StreamTokenizer.TT_EOF || tokenizer.sval == null)
throw new IllegalArgumentException("Value not specified for key '" + key + "' in JAAS config");
String value = tokenizer.sval;
options.put(key, value);
}
if (tokenizer.ttype != ';')
throw new IllegalArgumentException("JAAS config entry not terminated by semi-colon");
return new AppConfigurationEntry(loginModule, controlFlag, options);
}
示例6: JaasConfig
import java.io.StreamTokenizer; //導入方法依賴的package包/類
public JaasConfig(String loginContextName, String jaasConfigParams) {
StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(jaasConfigParams));
tokenizer.slashSlashComments(true);
tokenizer.slashStarComments(true);
tokenizer.wordChars('-', '-');
tokenizer.wordChars('_', '_');
tokenizer.wordChars('$', '$');
try {
configEntries = new ArrayList<>();
while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) {
configEntries.add(parseAppConfigurationEntry(tokenizer));
}
if (configEntries.isEmpty())
throw new IllegalArgumentException("Login module not specified in JAAS config");
this.loginContextName = loginContextName;
} catch (IOException e) {
throw new KafkaException("Unexpected exception while parsing JAAS config");
}
}
示例7: loadCmdFile
import java.io.StreamTokenizer; //導入方法依賴的package包/類
private static void loadCmdFile(String name, List args)
throws IOException
{
Reader r = new BufferedReader(new FileReader(name));
StreamTokenizer st = new StreamTokenizer(r);
st.resetSyntax();
st.wordChars(' ', 255);
st.whitespaceChars(0, ' ');
st.commentChar('#');
st.quoteChar('"');
st.quoteChar('\'');
while (st.nextToken() != st.TT_EOF) {
args.add(st.sval);
}
r.close();
}
示例8: parseBenchClass
import java.io.StreamTokenizer; //導入方法依賴的package包/類
Benchmark parseBenchClass(StreamTokenizer tokens)
throws IOException, ConfigFormatException
{
Benchmark bench;
switch (tokens.ttype) {
case StreamTokenizer.TT_WORD:
case '"':
try {
Class cls = Class.forName(tokens.sval);
bench = (Benchmark) cls.newInstance();
} catch (Exception e) {
throw new ConfigFormatException("unable to instantiate " +
"benchmark \"" + tokens.sval + "\" on line " +
tokens.lineno());
}
tokens.nextToken();
return bench;
default:
throw new ConfigFormatException("missing benchmark class " +
"name on line " + tokens.lineno());
}
}
示例9: skipBackSlash
import java.io.StreamTokenizer; //導入方法依賴的package包/類
/**
* Skips the back slash in the next token if it's followed by a new line.
*/
private static void skipBackSlash(StreamTokenizer tokenizer) throws IOException
{
tokenizer.ordinaryChar('\\');
if (tokenizer.nextToken() == '\\')
{
if (tokenizer.nextToken() != StreamTokenizer.TT_EOL)
{
throw new IncorrectFormatException("Expected new line after \\ character");
}
}
else
{
tokenizer.pushBack();
}
tokenizer.wordChars('\\', '\\');
}
示例10: unquote2
import java.io.StreamTokenizer; //導入方法依賴的package包/類
public static String unquote2(String str, boolean escapeHtml) {
if (str == null || str.equals("null")) {
return null;
}
StreamTokenizer parser = new StreamTokenizer(new StringReader(str));
String result;
try {
parser.nextToken();
if (parser.ttype == '"') {
result = parser.sval;
} else {
result = unquote(str, escapeHtml);
}
} catch (IOException e) {
result = unquote(str, escapeHtml);
}
return result;
}
示例11: loadCmdFile
import java.io.StreamTokenizer; //導入方法依賴的package包/類
private static void loadCmdFile(String name, ListBuffer<String> args)
throws IOException
{
Reader r = new BufferedReader(new FileReader(name));
StreamTokenizer st = new StreamTokenizer(r);
st.resetSyntax();
st.wordChars(' ', 255);
st.whitespaceChars(0, ' ');
st.commentChar('#');
st.quoteChar('"');
st.quoteChar('\'');
while (st.nextToken() != StreamTokenizer.TT_EOF) {
args.append(st.sval);
}
r.close();
}
示例12: parseSetSchema
import java.io.StreamTokenizer; //導入方法依賴的package包/類
private static HollowSetSchema parseSetSchema(String typeName, StreamTokenizer tokenizer) throws IOException {
int tok = tokenizer.nextToken();
if(tokenizer.ttype != '<')
throw new IOException("Invalid Syntax: Expected '<' after 'Set' for type " + typeName);
tok = tokenizer.nextToken();
if(tok != StreamTokenizer.TT_WORD) {
log.warning("Invalid Syntax: Expected element type declaration: " + typeName);
}
String elementType = tokenizer.sval;
tok = tokenizer.nextToken();
if(tokenizer.ttype != '>')
throw new IOException("Invalid Syntax: Expected '>' element type declaration: " + typeName);
tok = tokenizer.nextToken();
String hashKeyPaths[] = parseHashKey(tokenizer);
if(tokenizer.ttype != ';')
throw new IOException("Invalid Syntax: Expected semicolon after Set schema declaration: " + typeName);
return new HollowSetSchema(typeName, elementType, hashKeyPaths);
}
示例13: parse
import java.io.StreamTokenizer; //導入方法依賴的package包/類
@Override
public ParserState parse(StreamTokenizer st) throws IOException, ParseException
{
int token = st.ttype;
if (token != StreamTokenizer.TT_WORD || !st.sval.equals(ExpectedResultsParser.SECTION_IDENTIFIER))
{
throw new ParseException("expected line " + st.lineno() + " to begin with Section", st.lineno());
}
token = st.nextToken();
if (token != StreamTokenizer.TT_WORD && token != '"')
{
throw new ParseException("expected a section name on line " + st.lineno(), st.lineno());
}
String testName = st.sval;
token = st.nextToken();
String tableName = null;
if (token == StreamTokenizer.TT_WORD || token == '"')
{
tableName = st.sval;
token = st.nextToken();
}
this.getParser().startNewSection(testName, tableName);
if (token != StreamTokenizer.TT_EOL)
{
throw new ParseException("invalid data after the class name on line " + st.lineno(), st.lineno());
}
return this.getParser().getHeaderState();
}
示例14: getNextToken
import java.io.StreamTokenizer; //導入方法依賴的package包/類
/** Delivers the next token and checks for an unexpected end of line or file. */
public static void getNextToken(StreamTokenizer tokenizer) throws IOException {
if (tokenizer.nextToken() == StreamTokenizer.TT_EOL) {
throw new IOException("unexpected end of line " + tokenizer.lineno());
}
if (tokenizer.ttype == StreamTokenizer.TT_EOF) {
throw new IOException("unexpected end of file in line " + tokenizer.lineno());
} else if (tokenizer.ttype == '\'' || tokenizer.ttype == '"') {
tokenizer.ttype = StreamTokenizer.TT_WORD;
} else if (tokenizer.ttype == StreamTokenizer.TT_WORD && tokenizer.sval.equals("?")) {
tokenizer.ttype = '?';
}
}
示例15: waitForEOL
import java.io.StreamTokenizer; //導入方法依賴的package包/類
/** Skips all tokens before next end of line (EOL). */
public static void waitForEOL(StreamTokenizer tokenizer) throws IOException {
// skip everything until EOL
while (tokenizer.nextToken() != StreamTokenizer.TT_EOL) {
}
;
tokenizer.pushBack();
}