All pastes #797574 Raw Edit

Someone

public java v1 · immutable
#797574 ·published 2007-11-26 03:00 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<Person> persons = new ArrayList<Person>();	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(",");				// For each entry create a new person				Person person = new Person(cabecalho[0], Integer.parseInt(cabecalho[1]), cabecalho[2]);				persons.add(person);			}			in.close();		} catch (IOException e) {			System.out.println(e);			System.exit(-1);		}				for (int i=0; i<persons.size(); i++) {			Person person = persons.get(i);			System.out.print(person.getName() + " is " + person.getAge() + " years old ");			System.out.println("and uses the email: " + person.getEmail());			System.out.println();			System.out.println("When you wan't to write it to a file again you could just do something like this:");			System.out.println(person);		}	}}