Java Code Examples for java.io.StreamTokenizer#commentChar()
The following examples show how to use
java.io.StreamTokenizer#commentChar() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommandLine.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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(); }
Example 2
Source File: CommandLine.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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(); }
Example 3
Source File: CommandLine.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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(); }
Example 4
Source File: CommandLine.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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(); }
Example 5
Source File: CommandLine.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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(); }
Example 6
Source File: CommandLine.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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(); }
Example 7
Source File: CommandLine.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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(); }
Example 8
Source File: CommandLine.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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(); }
Example 9
Source File: CommandLine.java From hottub with GNU General Public License v2.0 | 6 votes |
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(); }
Example 10
Source File: CommandExecutor.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 11
Source File: ArffLoader.java From samoa with Apache License 2.0 | 6 votes |
private void initStreamTokenizer(Reader reader) { BufferedReader br = new BufferedReader(reader); //Init streamTokenizer streamTokenizer = new StreamTokenizer(br); streamTokenizer.resetSyntax(); streamTokenizer.whitespaceChars(0, ' '); streamTokenizer.wordChars(' ' + 1, '\u00FF'); streamTokenizer.whitespaceChars(',', ','); streamTokenizer.commentChar('%'); streamTokenizer.quoteChar('"'); streamTokenizer.quoteChar('\''); streamTokenizer.ordinaryChar('{'); streamTokenizer.ordinaryChar('}'); streamTokenizer.eolIsSignificant(true); this.instanceInformation = this.getHeader(); if (classAttribute < 0) { this.instanceInformation.setClassIndex(this.instanceInformation.numAttributes() - 1); //System.out.print(this.instanceInformation.classIndex()); } else if (classAttribute > 0) { this.instanceInformation.setClassIndex(classAttribute - 1); } }
Example 12
Source File: CommandLine.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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(); }
Example 13
Source File: ScriptingFunctions.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Break a string into tokens, honoring quoted arguments and escaped spaces. * * @param str a {@link String} to tokenize. * @return a {@link List} of {@link String}s representing the tokens that * constitute the string. */ 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; }
Example 14
Source File: Instances.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** * Initializes the StreamTokenizer used for reading the ARFF file. * * @param tokenizer * the stream tokenizer */ protected 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); }
Example 15
Source File: FileSourceBase.java From gama with GNU General Public License v3.0 | 5 votes |
/** * Method to override to configure the tokenizer behaviour. It is called each time a tokenizer is created (for the * parsed file and all included files). */ protected void configureTokenizer(final StreamTokenizer tok) throws IOException { if (COMMENT_CHAR > 0) { tok.commentChar(COMMENT_CHAR); } tok.quoteChar(QUOTE_CHAR); tok.eolIsSignificant(eol_is_significant); tok.wordChars('_', '_'); tok.parseNumbers(); }
Example 16
Source File: Board.java From megamek with GNU General Public License v2.0 | 5 votes |
/** * Checks if a board file is the specified size. * * @param filepath * The path to the board file. * @param size * The dimensions of the board to test. * @return {@code true} if the dimensions match. */ public static boolean boardIsSize(final File filepath, final BoardDimensions size) { int boardx = 0; int boardy = 0; try { // make inpustream for board Reader r = new BufferedReader(new FileReader(filepath)); // read board, looking for "size" StreamTokenizer st = new StreamTokenizer(r); st.eolIsSignificant(true); st.commentChar('#'); st.quoteChar('"'); st.wordChars('_', '_'); while (st.nextToken() != StreamTokenizer.TT_EOF) { if ((st.ttype == StreamTokenizer.TT_WORD) && st.sval.equalsIgnoreCase("size")) { st.nextToken(); boardx = (int) st.nval; st.nextToken(); boardy = (int) st.nval; break; } } r.close(); } catch (IOException ex) { return false; } // check and return return (boardx == size.width()) && (boardy == size.height()); }
Example 17
Source File: XYZApp.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** Create a Chemical model by parsing an input stream */ XYZChemModel(InputStream is) throws Exception { this(); StreamTokenizer st = new StreamTokenizer( new BufferedReader(new InputStreamReader(is, "UTF-8"))); st.eolIsSignificant(true); st.commentChar('#'); try { scan: while (true) { switch (st.nextToken()) { case StreamTokenizer.TT_EOF: break scan; default: break; case StreamTokenizer.TT_WORD: String name = st.sval; double x = 0, y = 0, z = 0; if (st.nextToken() == StreamTokenizer.TT_NUMBER) { x = st.nval; if (st.nextToken() == StreamTokenizer.TT_NUMBER) { y = st.nval; if (st.nextToken() == StreamTokenizer.TT_NUMBER) { z = st.nval; } } } addVert(name, (float) x, (float) y, (float) z); while (st.ttype != StreamTokenizer.TT_EOL && st.ttype != StreamTokenizer.TT_EOF) { st.nextToken(); } } // end Switch } // end while is.close(); } // end Try catch (IOException e) { } if (st.ttype != StreamTokenizer.TT_EOF) { throw new Exception(st.toString()); } }
Example 18
Source File: XYZApp.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** Create a Chemical model by parsing an input stream */ XYZChemModel(InputStream is) throws Exception { this(); StreamTokenizer st = new StreamTokenizer( new BufferedReader(new InputStreamReader(is, "UTF-8"))); st.eolIsSignificant(true); st.commentChar('#'); try { scan: while (true) { switch (st.nextToken()) { case StreamTokenizer.TT_EOF: break scan; default: break; case StreamTokenizer.TT_WORD: String name = st.sval; double x = 0, y = 0, z = 0; if (st.nextToken() == StreamTokenizer.TT_NUMBER) { x = st.nval; if (st.nextToken() == StreamTokenizer.TT_NUMBER) { y = st.nval; if (st.nextToken() == StreamTokenizer.TT_NUMBER) { z = st.nval; } } } addVert(name, (float) x, (float) y, (float) z); while (st.ttype != StreamTokenizer.TT_EOL && st.ttype != StreamTokenizer.TT_EOF) { st.nextToken(); } } // end Switch } // end while is.close(); } // end Try catch (IOException e) { } if (st.ttype != StreamTokenizer.TT_EOF) { throw new Exception(st.toString()); } }
Example 19
Source File: XYZApp.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** Create a Chemical model by parsing an input stream */ XYZChemModel(InputStream is) throws Exception { this(); StreamTokenizer st = new StreamTokenizer( new BufferedReader(new InputStreamReader(is, "UTF-8"))); st.eolIsSignificant(true); st.commentChar('#'); try { scan: while (true) { switch (st.nextToken()) { case StreamTokenizer.TT_EOF: break scan; default: break; case StreamTokenizer.TT_WORD: String name = st.sval; double x = 0, y = 0, z = 0; if (st.nextToken() == StreamTokenizer.TT_NUMBER) { x = st.nval; if (st.nextToken() == StreamTokenizer.TT_NUMBER) { y = st.nval; if (st.nextToken() == StreamTokenizer.TT_NUMBER) { z = st.nval; } } } addVert(name, (float) x, (float) y, (float) z); while (st.ttype != StreamTokenizer.TT_EOL && st.ttype != StreamTokenizer.TT_EOF) { st.nextToken(); } } // end Switch } // end while is.close(); } // end Try catch (IOException e) { } if (st.ttype != StreamTokenizer.TT_EOF) { throw new Exception(st.toString()); } }
Example 20
Source File: Harness.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Create new benchmark harness with given configuration and reporter. * Throws ConfigFormatException if there was an error parsing the config * file. * <p> * <b>Config file syntax:</b> * <p> * '#' marks the beginning of a comment. Blank lines are ignored. All * other lines should adhere to the following format: * <pre> * <weight> <name> <class> [<args>] * </pre> * <weight> is a floating point value which is multiplied times the * benchmark's execution time to determine its weighted score. The * total score of the benchmark suite is the sum of all weighted scores * of its benchmarks. * <p> * <name> is a name used to identify the benchmark on the benchmark * report. If the name contains whitespace, the quote character '"' should * be used as a delimiter. * <p> * <class> is the full name (including the package) of the class * containing the benchmark implementation. This class must implement * bench.Benchmark. * <p> * [<args>] is a variable-length list of runtime arguments to pass to * the benchmark. Arguments containing whitespace should use the quote * character '"' as a delimiter. * <p> * <b>Example:</b> * <pre> * 3.5 "My benchmark" bench.serial.Test first second "third arg" * </pre> */ public Harness(InputStream in) throws IOException, ConfigFormatException { Vector bvec = new Vector(); StreamTokenizer tokens = new StreamTokenizer(new InputStreamReader(in)); tokens.resetSyntax(); tokens.wordChars(0, 255); tokens.whitespaceChars(0, ' '); tokens.commentChar('#'); tokens.quoteChar('"'); tokens.eolIsSignificant(true); tokens.nextToken(); while (tokens.ttype != StreamTokenizer.TT_EOF) { switch (tokens.ttype) { case StreamTokenizer.TT_WORD: case '"': // parse line bvec.add(parseBenchInfo(tokens)); break; default: // ignore tokens.nextToken(); break; } } binfo = (BenchInfo[]) bvec.toArray(new BenchInfo[bvec.size()]); }