Expand|Select|Wrap|Line Numbers
- try{
- // Create file
- FileWriter fstream = new FileWriter("database.txt");
- BufferedWriter out = new BufferedWriter(fstream);
- for( int i=0; i<firsta.size(); i++)
- {
- out.write("First Name: "+firsta.get(i));
- out.write("Last Name: "+lasta.get(i));
- out.write("Age: "+agea.get(i));
- out.write("Street Address: "+streeta.get(i));
- out.write("City Name: "+citya.get(i));
- out.write("State Name: "+statea.get(i));
- out.write("Year: "+yeara.get(i));
- out.write("Gender: "+gendera.get(i));
- }
- //Close the output stream
- out.close();
- }catch (Exception e){//Catch exception if any
- System.out.println("Error: " + e.getMessage());
- }