本文整理匯總了Java中java.io.StreamTokenizer.quoteChar方法的典型用法代碼示例。如果您正苦於以下問題:Java StreamTokenizer.quoteChar方法的具體用法?Java StreamTokenizer.quoteChar怎麽用?Java StreamTokenizer.quoteChar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.io.StreamTokenizer
的用法示例。
在下文中一共展示了StreamTokenizer.quoteChar方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例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: 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: 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;
}
示例5: 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);
}
示例6: 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;
}
示例7: 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);
}
}
}
示例8: 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);
}
示例9: 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);
}
示例10: 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;
}
示例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() != st.TT_EOF) {
args.append(st.sval);
}
r.close();
}
示例12: 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;
}
示例13: getCookieTokens
import java.io.StreamTokenizer; //導入方法依賴的package包/類
/**
* Tokenizes a cookie header and returns the tokens in a
* <code>Vector</code>.
**/
private Vector getCookieTokens(String cookieHeader) {
StringReader sr = new StringReader(cookieHeader);
StreamTokenizer st = new StreamTokenizer(sr);
Vector tokens = new Vector();
// clear syntax tables of the StreamTokenizer
st.resetSyntax();
// set all characters as word characters
st.wordChars(0,Character.MAX_VALUE);
// set up characters for quoting
st.quoteChar( '"' ); //double quotes
st.quoteChar( '\'' ); //single quotes
// set up characters to separate tokens
st.whitespaceChars(59,59); //semicolon
st.whitespaceChars(44,44); //comma
try {
while (st.nextToken() != StreamTokenizer.TT_EOF) {
tokens.addElement( st.sval.trim() );
}
}
catch (IOException ioe) {
// this will never happen with a StringReader
}
sr.close();
return tokens;
}
示例14: Lexer
import java.io.StreamTokenizer; //導入方法依賴的package包/類
Lexer(String s) {
tok = new StreamTokenizer(new CharArrayReader(s.toCharArray()));
tok.quoteChar('"');
tok.parseNumbers();
tok.ordinaryChar(',');
tok.ordinaryChar('(');
tok.ordinaryChar(')');
tok.wordChars('$','$');
tok.wordChars('_','_');
}
示例15: 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(',', ',');
tokenizer.whitespaceChars(':', ':');
// tokenizer.whitespaceChars('.','.');
tokenizer.commentChar('|');
tokenizer.whitespaceChars('\t', '\t');
tokenizer.quoteChar('"');
tokenizer.quoteChar('\'');
tokenizer.eolIsSignificant(true);
}