PrintWriter fluxSortie = new PrintWriter(new BufferedWriter(new FileWriter( "D:\\nomFichier.txt"))); fluxSortie.write(lignes.get(i)+"\n"); fluxSortie.close();
public static List<String> lireFichier(String nomFichier){ BufferedReader fluxEntree=null; String ligneLue; List<String> lignes = new ArrayList<String>(); try{ fluxEntree = new BufferedReader(new FileReader(nomFichier)); ligneLue = fluxEntree.readLine(); while(ligneLue!=null){ lignes.add(ligneLue); ligneLue = fluxEntree.readLine(); } } catch(IOException exc){ exc.printStackTrace(); } try{ fluxEntree.close(); } catch(IOException e){ e.printStackTrace(); } return lignes; }