Util: Utilities for the building blocks examples

This is a code example of iText PDF, discover more.

21st June 2016
iText PDF

Switch code for this example

 * This example was written by Bruno Lowagie
 * in the context of the book: iText 7 building blocks
package com.itextpdf.highlevel.util;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

 * @author iText
public class CsvTo2DList {
    public static final List> convert(String src, String separator) throws IOException {
        List> resultSet = new ArrayList<>();
        BufferedReader br = new BufferedReader(
            new InputStreamReader(new FileInputStream(src), "UTF8"));
        String line;
        List record;
        while ((line = br.readLine()) != null) {
            StringTokenizer tokenizer = new StringTokenizer(line, separator);
            record = new ArrayList<>();
            while (tokenizer.hasMoreTokens()) {
        return resultSet;

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now