当前位置: 首页>>代码示例>>Java>>正文


Java StreamTokenizer类代码示例

本文整理汇总了Java中java.io.StreamTokenizer的典型用法代码示例。如果您正苦于以下问题:Java StreamTokenizer类的具体用法?Java StreamTokenizer怎么用?Java StreamTokenizer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StreamTokenizer类属于java.io包,在下文中一共展示了StreamTokenizer类的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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:Harness.java

示例2: 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:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:CommandLine.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:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:CommandLine.java

示例4: toMessage

import java.io.StreamTokenizer; //导入依赖的package包/类
public String toMessage() {
    switch(ttype) {
    case StreamTokenizer.TT_EOL:
        return "\"EOL\"";
    case StreamTokenizer.TT_EOF:
        return "\"EOF\"";
    case StreamTokenizer.TT_NUMBER:
        return "NUMBER";
    case StreamTokenizer.TT_WORD:
        if (sval == null) {
            return "IDENTIFIER";
        } else {
            return "IDENTIFIER " + sval;
        }
    default:
        if (ttype == (int)'"') {
            String msg = "QUOTED STRING";
            if (sval != null)
                msg = msg + " \"" + sval + "\"";
            return msg;
        } else {
            return "CHARACTER \'" + (char)ttype + "\'";
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:Token.java

示例5: 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

示例6: next

import java.io.StreamTokenizer; //导入依赖的package包/类
Token next() throws IOException {
  int type = tok.nextToken();
  switch (type) {
    case StreamTokenizer.TT_EOF:
    case StreamTokenizer.TT_EOL:
      return null;
    case StreamTokenizer.TT_NUMBER:
      return new NumToken(tok.nval);
    case StreamTokenizer.TT_WORD:
      return new StrToken(TType.IDENT, tok.sval);
    case '"':
      return new StrToken(TType.QUOT, tok.sval);
    default:
      switch (type) {
        case ',':
          return new Token(TType.COMMA);
        case '(':
          return new Token(TType.LPAREN);
        case ')':
          return new Token(TType.RPAREN);
        default:
          throw new IOException("Unexpected: " + type);
      }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:Parser.java

示例7: 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

示例8: 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

示例9: 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

示例10: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:Harness.java

示例11: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:Harness.java

示例12: parse

import java.io.StreamTokenizer; //导入依赖的package包/类
private Void parse(Reader reader) throws ParseException, IOException
{
    StreamTokenizer st = new StreamTokenizer(reader);
    st.eolIsSignificant(true);
    st.wordChars((int) '_', (int) '_');
    st.parseNumbers();
    st.quoteChar((int) '"');
    // These calls caused comments to be discarded
    st.slashSlashComments(true);
    st.slashStarComments(true);

    // Parse the file
    ParserState currentState = this.getBeginningOfLineState();
    while (currentState != null)
    {
        currentState = currentState.parse(st);
    }
    return null;
}
 
开发者ID:goldmansachs,项目名称:tablasco,代码行数:20,代码来源:ExpectedResultsParser.java

示例13: parse

import java.io.StreamTokenizer; //导入依赖的package包/类
@Override
public ParserState parse(StreamTokenizer st) throws IOException, ParseException
{
    ParserState nextState = null;
    while (nextState == null && st.ttype != StreamTokenizer.TT_EOF)
    {
        int nextToken = st.nextToken();
        if (nextToken != StreamTokenizer.TT_EOL && nextToken != StreamTokenizer.TT_EOF)
        {
            if (nextValueIs(ExpectedResultsParser.SECTION_IDENTIFIER, st, nextToken))
            {
                nextState = this.getParser().getSectionReaderState();
            }
            else if (nextValueIs(ExpectedResultsParser.METADATA_IDENTIFIER, st, nextToken))
            {
                nextState = this.getParser().getMetadataReaderState();
            }
            else
            {
                nextState = this.getParser().getDataReaderState();
            }
        }
    }
    return nextState;
}
 
开发者ID:goldmansachs,项目名称:tablasco,代码行数:26,代码来源:BeginningOfLineState.java

示例14: setJobTemplateCommand

import java.io.StreamTokenizer; //导入依赖的package包/类
private static void setJobTemplateCommand(JobTemplate jt, String line) throws IOException, DrmaaException {
	Reader r = new StringReader(line);
	StreamTokenizer tokenizer = new StreamTokenizer(r);
	tokenizer.quoteChar('"');
	tokenizer.quoteChar('\'');
	String cmd = null;
	List<String> args = new ArrayList<String>();
	for (int tok = tokenizer.nextToken(); tok != StreamTokenizer.TT_EOF; tok = tokenizer.nextToken()) {
		if (tok == StreamTokenizer.TT_WORD || tok == StreamTokenizer.TT_NUMBER) {
			if (cmd == null) {
				cmd = tokenizer.sval;
			}
			else {
				args.add(tokenizer.sval);
			}
		}
	}
	jt.setRemoteCommand(cmd);
	jt.setArgs(args);
}
 
开发者ID:Bibliome,项目名称:bibliome-java-utils,代码行数:21,代码来源:FileJobSpecificationBuilder.java

示例15: parseArgsLine

import java.io.StreamTokenizer; //导入依赖的package包/类
/**
 * Parses a option line likes
 *    -genkaypair -dname "CN=Me"
 * and add the results into a list
 * @param list the list to fill into
 * @param s the line
 */
private static void parseArgsLine(List<String> list, String s)
        throws IOException, PropertyExpander.ExpandException {
    StreamTokenizer st = new StreamTokenizer(new StringReader(s));

    st.resetSyntax();
    st.whitespaceChars(0x00, 0x20);
    st.wordChars(0x21, 0xFF);
    // Everything is a word char except for quotation and apostrophe
    st.quoteChar('"');
    st.quoteChar('\'');

    while (true) {
        if (st.nextToken() == StreamTokenizer.TT_EOF) {
            break;
        }
        list.add(PropertyExpander.expand(st.sval));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:KeyStoreUtil.java


注:本文中的java.io.StreamTokenizer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。