Xj3D 2.0 VRML/X3D Code API

org.web3d.vrml.parser
Class VRMLParserUtils

java.lang.Object
  extended by org.web3d.vrml.parser.VRMLParserUtils

public class VRMLParserUtils
extends java.lang.Object

General convenience utilities for handling parsing of VRML files.

Version:
$Revision: 1.3 $
Author:
Justin Couch

Method Summary
static java.lang.String[] parseFileHeader(java.io.InputStream stream)
          Take the stream and strip the first line out of it to check that it is a vrml file.
static java.lang.String[] parseFileHeader(java.io.Reader stream)
          Take the reader and strip the first line out of it to check that it is a vrml file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parseFileHeader

public static java.lang.String[] parseFileHeader(java.io.InputStream stream)
                                          throws java.io.IOException
Take the stream and strip the first line out of it to check that it is a vrml file. If it is, return an array of the contents of the first line. The array is arranged as:
ret_val[0] = "#VRML" or "#X3D"
ret_val[1] = version string ("V2.0", "V3.0" etc)
ret_val[2] = encoding type ("utf8" usually)
ret_val[3] = The rest of the line - a comment

If the first two characters are not "#V" then this will terminate and not read the characters any further. The first two characters will be returned as a string in the first item and only in the array. The items in the array are built based on whitespace separators. That is, we don't explicitly look for these strings, but rather just give the next whitespace separated token. If we run out of tokens then any remaining items in the array are set to null.

Parameters:
stream - The input stream to source characters from.
Returns:
An array of the items of the header
Throws:
java.io.IOException - Something happened while reading the stream

parseFileHeader

public static java.lang.String[] parseFileHeader(java.io.Reader stream)
                                          throws java.io.IOException
Take the reader and strip the first line out of it to check that it is a vrml file. If it is, return an array of the contents of the first line. The output and assumptions are the same as the version of this method that takes an InputStream.

Parameters:
stream - The input stream to source characters from.
Returns:
An array of the items of the header
Throws:
java.io.IOException - Something happened while reading the stream
See Also:
parseFileHeader(java.io.InputStream)

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium