I have a problem. I'm looking for a code to use in my FileWriter. I want to write my array list to text file, but i dont know how can you help me
package javaapplication1;
import java.io.*; import java.util.*;
public class Namen { public static void main(String args[]) {
FileWriter uit; try{ uit = new FileWriter("Namen van de groep.txt"); System.out.println("Bestand wordt nu gemaakt..."); List list = new ArrayList(); list.add("Roepesh"); list.add("Perasad"); list.add("Preshand"); list.add("Jezus"); list.add("Aviblaas"); Iterator ikIterator = list.iterator(); while (ikIterator.hasNext()) {
System.out.println(ikIterator.next());
Object naam = ikIterator.next(); uit.write(naam); } uit.close(); System.out.println( "Bestand is gesloten" );
} catch( IOException e ){ System.out.println( " Fout bij het openen, maken of sluiten bestand" ); e.printStackTrace(); } }