
package escrituracadenas;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class EscrituraCadenas {

    public static void main(String[] args)  {   
       try {       
             String cadenaIntroducida;
             BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
             FileWriter fileWriter = new FileWriter(new File("D:\\archivos_creados_Java\\cadenas.dat"));
             PrintWriter printWriter = new PrintWriter(fileWriter);
             System.out.println("Introduzca cadenas a ser almacenados en archivo. Teclee Intro para finalizar : ");
             while ((cadenaIntroducida = bufferedReader.readLine()).compareTo("") != 0) {
                 printWriter.println(cadenaIntroducida);
             }
             fileWriter.close();
           } catch (Exception e)
              {System.out.println(e);}        
    }   
}
