本文整理汇总了Java中java.io.StreamTokenizer.wordChars方法的典型用法代码示例。如果您正苦于以下问题:Java StreamTokenizer.wordChars方法的具体用法?Java StreamTokenizer.wordChars怎么用?Java StreamTokenizer.wordChars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.StreamTokenizer
的用法示例。
在下文中一共展示了StreamTokenizer.wordChars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTokenizer
import java.io.StreamTokenizer; //导入方法依赖的package包/类
/**
* createTokenizer - build up StreamTokenizer for the command script
* @param script command script to parsed
* @return StreamTokenizer for command script
*/
private static StreamTokenizer createTokenizer(final String script) {
final StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(script));
tokenizer.resetSyntax();
// Default all characters to word.
tokenizer.wordChars(0, 255);
// Spaces and special characters are white spaces.
tokenizer.whitespaceChars(0, ' ');
// Ignore # comments.
tokenizer.commentChar('#');
// Handle double and single quote strings.
tokenizer.quoteChar('"');
tokenizer.quoteChar('\'');
// Need to recognize the end of a command.
tokenizer.eolIsSignificant(true);
// Command separator.
tokenizer.ordinaryChar(';');
// Pipe separator.
tokenizer.ordinaryChar('|');
return tokenizer;
}
示例2: 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();
}
示例3: 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");
}
}
示例4: 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();
}
示例5: setup
import java.io.StreamTokenizer; //导入方法依赖的package包/类
/**
* Sets up the stream tokenizer
*/
private void setup() {
st = new StreamTokenizer(this);
st.resetSyntax();
st.eolIsSignificant(false);
st.lowerCaseMode(true);
// Parse numbers as words
st.wordChars('0', '9');
st.wordChars('-', '.');
// Characters as words
st.wordChars('\u0000', '\u00FF');
// Skip comments
st.commentChar('%');
// Skip whitespace and newlines
st.whitespaceChars(' ', ' ');
st.whitespaceChars('\u0009', '\u000e');
}
示例6: 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;
}
示例7: 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));
}
}
示例8: loadCmdFile
import java.io.StreamTokenizer; //导入方法依赖的package包/类
private static void loadCmdFile(String name, ListBuffer<String> args)
throws IOException
{
try (Reader r = Files.newBufferedReader(Paths.get(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);
}
}
}
示例9: initTokenizer
import java.io.StreamTokenizer; //导入方法依赖的package包/类
/**
* Initializes the stream tokenizer.
*
* @param tokenizer the tokenizer to initialize
*/
private void initTokenizer(StreamTokenizer tokenizer) {
tokenizer.resetSyntax();
tokenizer.whitespaceChars(0, (' ' - 1));
tokenizer.wordChars(' ', '\u00FF');
tokenizer.whitespaceChars(m_FieldSeparator.charAt(0),
m_FieldSeparator.charAt(0));
// tokenizer.commentChar('%');
String[] parts = m_Enclosures.split(",");
for (String e : parts) {
if (e.length() > 1 || e.length() == 0) {
throw new IllegalArgumentException(
"Enclosures can only be single characters");
}
tokenizer.quoteChar(e.charAt(0));
}
tokenizer.eolIsSignificant(true);
}
示例10: setSyntax
import java.io.StreamTokenizer; //导入方法依赖的package包/类
/**
* This method sets the syntax of the StreamTokenizer. i.e. set the
* whitespace, comment and delimit chars.
*
*/
protected void setSyntax(StreamTokenizer tk) {
tk.resetSyntax();
tk.eolIsSignificant(false);
tk.slashStarComments(true);
tk.slashSlashComments(true);
tk.whitespaceChars(0, ' ');
tk.wordChars(' ' + 1, '\u00ff');
tk.ordinaryChar('[');
tk.ordinaryChar(']');
tk.ordinaryChar('{');
tk.ordinaryChar('}');
tk.ordinaryChar('-');
tk.ordinaryChar('>');
tk.ordinaryChar('/');
tk.ordinaryChar('*');
tk.quoteChar('"');
tk.whitespaceChars(';', ';');
tk.ordinaryChar('=');
}
示例11: readConfig
import java.io.StreamTokenizer; //导入方法依赖的package包/类
private void readConfig(Reader reader, HashMap newConfig)
throws IOException {
if (!(reader instanceof BufferedReader))
reader = new BufferedReader(reader);
st = new StreamTokenizer(reader);
st.quoteChar('"');
st.wordChars('$', '$');
st.wordChars('_', '_');
st.wordChars('-', '-');
st.lowerCaseMode(false);
st.slashSlashComments(true);
st.slashStarComments(true);
st.eolIsSignificant(true);
lookahead = nextToken();
while (lookahead != StreamTokenizer.TT_EOF) {
parseLoginEntry(newConfig);
}
}
示例12: 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();
}
示例13: initTokenizer
import java.io.StreamTokenizer; //导入方法依赖的package包/类
/**
* Initializes the StreamTokenizer used for reading the ARFF file.
*/
private void initTokenizer(StreamTokenizer tokenizer) {
tokenizer.resetSyntax();
tokenizer.whitespaceChars(0, ' ');
tokenizer.wordChars(' ' + 1, '\u00FF');
tokenizer.whitespaceChars(',', ',');
tokenizer.commentChar('%');
tokenizer.quoteChar('"');
tokenizer.quoteChar('\'');
tokenizer.ordinaryChar('{');
tokenizer.ordinaryChar('}');
tokenizer.eolIsSignificant(true);
}
示例14: createTokenizer
import java.io.StreamTokenizer; //导入方法依赖的package包/类
/**
* Creates a tokenizer for the specified string.
*/
private StreamTokenizer createTokenizer(String str) {
StreamTokenizer t = new StreamTokenizer(new StringReader(str));
t.resetSyntax();
t.wordChars((char) 33, (char) 126);
t.ordinaryChar(':');
t.ordinaryChar('/');
t.quoteChar('"');
t.quoteChar('\'');
t.whitespaceChars(' ', ' ');
t.whitespaceChars('\t', '\t');
return t;
}
示例15: tokenizeString
import java.io.StreamTokenizer; //导入方法依赖的package包/类
public static List<String> tokenizeString(final String str) {
final StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(str));
tokenizer.resetSyntax();
tokenizer.wordChars(0, 255);
tokenizer.whitespaceChars(0, ' ');
tokenizer.commentChar('#');
tokenizer.quoteChar('"');
tokenizer.quoteChar('\'');
final List<String> tokenList = new ArrayList<>();
final StringBuilder toAppend = new StringBuilder();
while (nextToken(tokenizer) != StreamTokenizer.TT_EOF) {
final String s = tokenizer.sval;
// The tokenizer understands about honoring quoted strings and recognizes
// them as one token that possibly contains multiple space-separated words.
// It does not recognize quoted spaces, though, and will split after the
// escaping \ character. This is handled here.
if (s.endsWith("\\")) {
// omit trailing \, append space instead
toAppend.append(s.substring(0, s.length() - 1)).append(' ');
} else {
tokenList.add(toAppend.append(s).toString());
toAppend.setLength(0);
}
}
if (toAppend.length() != 0) {
tokenList.add(toAppend.toString());
}
return tokenList;
}