Java CSV String Split tokenizeCsv(String input)

Here you can find the source of tokenizeCsv(String input)

Description

tokenize Csv

License

Open Source License

Declaration

public static final List<String> tokenizeCsv(String input) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    /** CSV config separator. */
    private static final String COMMA = ",";

    public static final List<String> tokenizeCsv(String input) {
        List<String> result = new ArrayList<String>();

        if (null != input && !input.isEmpty()) {

            String[] tokens = input.trim().split(COMMA);
            if (null != tokens && tokens.length > 0) {

                for (String token : tokens) {
                    String sanitizedToken = token.trim();

                    if (!sanitizedToken.isEmpty()) {
                        result.add(sanitizedToken);
                    }/*from  w  ww  .  j a  va2 s .co m*/

                }

            }

        }

        return result;
    }
}

Related

  1. splitCSV(String str)
  2. splitCSV(String str)
  3. splitCSV(String str)
  4. splitCSV(String str, String delim)
  5. SplitCSVString(String str)
  6. toTable(String csv)