當前位置: 首頁>>代碼示例>>Java>>正文


Java StreamTokenizer.nextToken方法代碼示例

本文整理匯總了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());
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:Harness.java

示例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());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:Harness.java

示例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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:CommandLine.java

示例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());
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:22,代碼來源:Harness.java

示例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);
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:18,代碼來源:JaasConfig.java

示例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");
    }
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:23,代碼來源:JaasConfig.java

示例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();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:CommandLine.java

示例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());
    }
}
 
開發者ID:JetBrains,項目名稱:jdk8u_jdk,代碼行數:24,代碼來源:Harness.java

示例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('\\', '\\');
}
 
開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:20,代碼來源:OBJLoader.java

示例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;
}
 
開發者ID:osonus,項目名稱:oson,代碼行數:20,代碼來源:StringUtil.java

示例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();
}
 
開發者ID:ojdkbuild,項目名稱:lookaside_java-1.8.0-openjdk,代碼行數:17,代碼來源:CommandLine.java

示例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);
}
 
開發者ID:Netflix,項目名稱:hollow,代碼行數:26,代碼來源:HollowSchemaParser.java

示例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();
}
 
開發者ID:goldmansachs,項目名稱:tablasco,代碼行數:33,代碼來源:SectionReaderState.java

示例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 = '?';
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:15,代碼來源:Tools.java

示例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();
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:9,代碼來源:Tools.java


注:本文中的java.io.StreamTokenizer.nextToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。