All pastes #797577 Raw Edit

Stuff

public java v1 · immutable
#797577 ·published 2007-11-26 03:10 UTC
rendered paste body
import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.ArrayList;public class readFile {	private static String arquivo = "testfile.txt";	private static String cabecalho[];	// Use this to save the persons read from the file	private static ArrayList<ArrayList<String>> persons = new ArrayList<ArrayList<String>>();	public static void main(String[] args) {		try {			BufferedReader in = new BufferedReader(new FileReader(arquivo));			String str;			// Read and parse the file			while ((str = in.readLine()) != null) {				cabecalho = str.split(",");								ArrayList<String> person = new ArrayList<String>();								for(int i=0; i<cabecalho.length; i++) {					person.add(cabecalho[i]);				}				// For each entry create a new person				persons.add(person);			}			in.close();		} catch (IOException e) {			System.out.println(e);			System.exit(-1);		}				for (int i=0; i<persons.size(); i++) {			// You could of course loop through this and set it up nicely, but I believe this should do the trick			System.out.println(persons);		}	}}