
package escrituracaracteres;

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

public class EscrituraCaracteres {

    public static void main(String[] args)  {   
       int caracter;
       try {          
             InputStreamReader inputStreamReader = new InputStreamReader(System.in);
             FileWriter fileWriter = new FileWriter(new File("D:\\archivos_creados_Java\\caracteres.dat"));
             System.out.print("Introduzca caracteres a ser almacenados en archivo. Pulse intro para finalizar : ");
             while ((caracter  = inputStreamReader.read()) != '\n') {
                fileWriter.write(caracter);
             }
             fileWriter.close();
           } catch (Exception e)
              {System.out.println(e);}        
    }   
}
