Package com.bbn.openmap.util

Examples of com.bbn.openmap.util.CSVTokenizer


            URL csvURL = PropUtils.getResourceOrFileOrURL(null, locationFile);
            if (csvURL == null) {

            }
            streamReader = new BufferedReader(new InputStreamReader(csvURL.openStream()));
            CSVTokenizer csvt = new CSVTokenizer(streamReader);

            token = csvt.token();

            while (!csvt.isEOF(token)) {
                int i = 0;

                Debug.message("csvlocation",
                        "CSVLocationHandler| Starting a line | have"
                                + (readHeader ? " " : "n't ") + "read header");

                while (!csvt.isNewline(token) && !csvt.isEOF(token)) {

                    if (readHeader) {
                        tokenHandler.handleToken(token, i);
                    }

                    token = csvt.token();
                    // For some reason, the check above doesn't always
                    // work
                    if (csvt.isEOF(token)) {
                        break;
                    }
                    i++;
                }

                if (!readHeader) {
                    readHeader = true;
                } else {
                    lineCount++;
                    tokenHandler.createAndAddObjectFromTokens(qt);
                }
                token = csvt.token();
            }
        } catch (java.io.IOException ioe) {
            throw new com.bbn.openmap.util.HandleError(ioe);
        } catch (ArrayIndexOutOfBoundsException aioobe) {
            throw new com.bbn.openmap.util.HandleError(aioobe);
View Full Code Here


            // This lets the property be specified as a file name
            // even if it's not specified as file:/<name> in
            // the properties file.
            URL csvURL = infoUrl;
            streamReader = new BufferedReader(new InputStreamReader(csvURL.openStream()));
            CSVTokenizer csvt = new CSVTokenizer(streamReader, readNumbersAsStrings);
            int count = 0;
            token = csvt.token();
            while (!csvt.isEOF(token)) {
                count++;

                Vector rec_line = new Vector();
                while (!csvt.isNewline(token)) {
                    rec_line.addElement(token);
                    token = csvt.token();
                    if (csvt.isEOF(token))
                        break;
                }

                //  Don't add the header record, because we don't care
                //  about it.
                if (header_read) {
                    records.addElement(rec_line);
                } else if (headersExist) {
                    headerRecord = rec_line;
                    header_read = true;
                }

                if (Debug.debugging("csv")) {
                    Debug.output("CSVFile.read: " + rec_line);
                }

                token = csvt.token();
            }
        } catch (java.io.IOException ioe) {
            throw new com.bbn.openmap.util.HandleError(ioe);
        } catch (ArrayIndexOutOfBoundsException aioobe) {
            throw new com.bbn.openmap.util.HandleError(aioobe);
View Full Code Here

TOP

Related Classes of com.bbn.openmap.util.CSVTokenizer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.