Example usage for java.io StreamTokenizer toString

List of usage examples for java.io StreamTokenizer toString

Introduction

In this page you can find the example usage for java.io StreamTokenizer toString.

Prototype

public String toString() 

Source Link

Document

Returns the string representation of the current stream token and the line number it occurs on.

Usage

From source file:edu.umd.cfar.lamp.viper.util.StringHelp.java

/** 
 * Checks to see if the file begins with an xml processing directive, eg
 * <code>&lt;?xml?&gt;</code>. This method does not check to see that the 
 * file is well-formed, or even if the processing directive is good, just that
 * the first non-whitespace characters are "&lt;?xml".
 *
 * @param f The file to check for xml processing directive
 * @throws IOException if there is an error while reading the file, eg FileNotFoundException
 * @return <code>true</code> if the directive was found. 
 *//*w ww  .ja v a  2 s .  c o m*/
public static boolean isXMLFormat(File f) throws IOException {
    StreamTokenizer st = new StreamTokenizer(new FileReader(f));
    st.wordChars('<', '<');
    st.wordChars('>', '>');
    st.wordChars('?', '?');
    st.nextToken();
    return st.toString().startsWith("Token[<?xml");
}