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


Java StreamTokenizer.resetSyntax方法代碼示例

本文整理匯總了Java中java.io.StreamTokenizer.resetSyntax方法的典型用法代碼示例。如果您正苦於以下問題:Java StreamTokenizer.resetSyntax方法的具體用法?Java StreamTokenizer.resetSyntax怎麽用?Java StreamTokenizer.resetSyntax使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.StreamTokenizer的用法示例。


在下文中一共展示了StreamTokenizer.resetSyntax方法的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();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:CommandLine.java

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

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

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

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

示例6: 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');
}
 
開發者ID:opprop-benchmarks,項目名稱:matrix-toolkits-java,代碼行數:24,代碼來源:MatrixVectorReader.java

示例7: 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);
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:25,代碼來源:CSVLoader.java

示例8: 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('=');
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:25,代碼來源:DotParser.java

示例9: createTokenizer

import java.io.StreamTokenizer; //導入方法依賴的package包/類
/**
 * Returns a new tokenizer for an OBJ or MTL stream.
 */
private static StreamTokenizer createTokenizer(Reader reader)
{
	StreamTokenizer tokenizer = new StreamTokenizer(reader);
	tokenizer.resetSyntax();
	tokenizer.eolIsSignificant(true);
	
	// All printable ASCII characters
	tokenizer.wordChars('!', '~');
	// Let's tolerate other ISO-8859-1 characters
	tokenizer.wordChars(0x80, 0xFF);
	
	tokenizer.whitespaceChars(' ', ' ');
	tokenizer.whitespaceChars('\n', '\n');
	tokenizer.whitespaceChars('\r', '\r');
	tokenizer.whitespaceChars('\t', '\t');
	return tokenizer;
}
 
開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:21,代碼來源:OBJLoader.java

示例10: 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);
}
 
開發者ID:takun2s,項目名稱:smile_1.5.0_java7,代碼行數:16,代碼來源:ArffParser.java

示例11: 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;
  }
 
開發者ID:eric-roberts,項目名稱:JavaPPTX,代碼行數:17,代碼來源:OptionParser.java

示例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() != st.TT_EOF) {
        args.append(st.sval);
    }
    r.close();
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:16,代碼來源:CommandLine.java

示例13: parseQuoteTokens

import java.io.StreamTokenizer; //導入方法依賴的package包/類
/**
* Parse specified string into tokens. Content surrounded with &quot; character
* is considered as a single token. For example: echo "hello world" will be parsed 
* into two tokens, respectively [echo], and [hello world]. The quote character 
* itself can be quoted and escaped in order to return as ordinary character. For 
* example: echo "hello \" world" will be parsed into two tokens: [echo] and 
* [hello " world].
* @param string
* @return
*/
  public static String[] parseQuoteTokens(String string) {
  	List<String> commandTokens = new ArrayList<String>();
  	
StreamTokenizer st = new StreamTokenizer(
		new BufferedReader(new StringReader(string)));
st.resetSyntax();
st.wordChars(0, 255);
st.ordinaryChar(' ');
st.ordinaryChar('\n');
st.ordinaryChar('\t');
st.ordinaryChar('\r');
st.quoteChar('"');

try {
	String token = null;
	while (st.nextToken() != StreamTokenizer.TT_EOF) {
		if (st.ttype == '"' || st.ttype == StreamTokenizer.TT_WORD) {
			if (token == null)
				token = st.sval;
			else
				token += st.sval;
		} else if (token != null) {
			commandTokens.add(token);
			token = null;
		}
	}
	if (token != null)
		commandTokens.add(token);
} catch (IOException e) {
	throw new RuntimeException(e);
}

return commandTokens.toArray(new String[commandTokens.size()]);
  }
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:45,代碼來源:StringUtils.java

示例14: 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;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:35,代碼來源:CookieJar.java

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


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