Package ariba.util.io

Examples of ariba.util.io.CSVReader


       These Strings are trimed and converted into lower case.
    */
    private static String[] readFileToStrings (URL url)
    {
        ContentCollector collector = new ContentCollector();
        CSVReader reader = new CSVReader(collector);
        try {
            reader.read(url, "8859_1");
        }
        catch (IOException ioe) {
            Log.aribaweb.warn(Fmt.S("Failed to read from %s", url));
            return null;
        }
View Full Code Here


        }

        public List<String> keys ()
        {
            // read first line (we have to launch a read and then bail out upon the first callback)
            CSVReader reader = new CSVReader(this);
            InputStream is = null;
            try {
                is = _url.openStream();
                Reader in = IOUtil.bufferedReader(is, I18NUtil.EncodingUTF8);
                reader.read(in, _url.toString());
            } catch (IOException e) {
                throw new AWGenericException(e);
            } catch (AbortedRead e) {
                // expected... ignore
                try {
View Full Code Here

        }

        public void readAll (LineConsumer consumer)
        {
            _consumer = consumer;
            CSVReader reader = new CSVReader(this);
            try {
                reader.read(_url, I18NUtil.EncodingUTF8);
            } catch (IOException e) {
                throw new AWGenericException(e);
            } catch (AbortedRead e) {
                // expected... ignore
            }
View Full Code Here

            if (!URLUtil.maybeURLExists(url)) {
                return null;
            }

            in = url.openStream();
            CSVReader reader = new CSVReader(consumer);
            reader.readForSpecifiedEncoding(in, url.toString());
            return reader;
        }
        catch (IOException e) {
            throw new AWGenericException(e);
        }
View Full Code Here

        {
            StringFile stringFile = stringsForFile.get(file);
            if (stringFile == null) {
                URL url = URLUtil.url(file);
                CSVStringConsumer csvConsumer = new CSVStringConsumer(url, true);
                CSVReader reader = loadStringsFromCSV(url, csvConsumer);
                List<LString> strings = new ArrayList();
                for (List<String> line : csvConsumer.getLines()) {
                    while (line.size() < 5) line.add("");
                    strings.add(new LString(line.get(0),line.get(1),line.get(2),line.get(3),line.get(4)));
                }
                stringFile = new StringFile(file, strings,
                        (reader.isEncodingExplicitlySet()) ? reader.getEncoding() : null);
                stringsForFile.put(file, stringFile);
            }
            return stringFile;
        }
View Full Code Here

            InputStream in = resource.inputStream();
            // File format:
            // "ISO_CODE","ISO_NUMERIC","NAME","PREFIX","SUFFIX","CURRENCY_GROUP","SCALE","IS_SUPPORTED","ACTIVE_BEGIN_DATE","ACTIVE_END_DATE"
            try {
                CSVReader reader = new CSVReader(new CSVConsumer() {
                    public void consumeLineOfTokens (String path, int lineNumber, List line)
                    {
                        if (lineNumber == 1) return;
                        List<String> l = line;
                        Currency currency = new Currency(l.get(0), l.get(3), l.get(4), Integer.parseInt(l.get(6)));
                        _Currencies.put(currency.getCode(), currency);
                    }
                });
                reader.readForSpecifiedEncoding(in, resource.relativePath(), "UTF-8");
            }
            catch (IOException e) {
                throw new AWGenericException(e);
            }
            finally {
View Full Code Here

    */
    public void verifyCSV (InputStream resourceStream, String filePath)
    throws IOException
    {
        StringCSVConsumer consumer = new CSVStringTableConsumer(filePath, false);
        CSVReader reader = new CSVReader(consumer);
        try {
            reader.readForSpecifiedEncoding(resourceStream, filePath);
        }
        catch (TunnelingException ex) {
            throw (IOException)ex.getNestedException();
        }
        finally {
View Full Code Here

            if (!URLUtil.maybeURLExists(url)) {
                return null;
            }

            in = url.openStream();
            CSVReader reader = new CSVReader(consumer);
            reader.readForSpecifiedEncoding(in, url.toString());
            return consumer.getStrings();
        }
        catch (TunnelingException ex) {
            /* this only happens when the StringCSVConsumer has an exception
               current behavior is to assert */
 
View Full Code Here

    }

    public static AWTCSVDataSource dataSourceForFile (File file)
    {
        AWTCSVDataSource dataSource = new AWTCSVDataSource();
        CSVReader reader = new CSVReader(dataSource);
        try {
            reader.read(file, I18NUtil.EncodingUTF8);
        } catch (IOException e) {
            throw new AWGenericException(e);
        }
        return dataSource;
    }
View Full Code Here

    }

    public static AWTCSVDataSource dataSourceForURL (URL url)
    {
        AWTCSVDataSource dataSource = new AWTCSVDataSource();
        CSVReader reader = new CSVReader(dataSource);
        try {
            reader.read(url, I18NUtil.EncodingUTF8);
        } catch (IOException e) {
            throw new AWGenericException(e);
        }
        return dataSource;
    }
View Full Code Here

TOP

Related Classes of ariba.util.io.CSVReader

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.