Archivos_1.java_



import java.io.*;

public class Archivos_1
{
   static FileOutputStream fe = null, ff = null, fs = null;
   static FileInputStream  se = null, sf = null, ss = null;

   static String PideDato(String Mensaje) throws IOException
   {
      BufferedReader EntradaDeTeclado = new BufferedReader(new InputStreamReader(System.in));
      System.out.print(Mensaje + " ");
      System.out.flush();
      return EntradaDeTeclado.readLine();
   }

   public static void main(String args[]) throws IOException
   {
      fe = new FileOutputStream("Enteros.txt");
      ff = new FileOutputStream("Flotantes.txt");
      fs = new FileOutputStream("Cadenas.txt");

      String Opcion = "";

      while(true)
      {
         System.out.println("1.- Entero");
         System.out.println("2.- Flotante");
         System.out.println("3.- Cadenas");
         System.out.println("4.- Mostrar");
         System.out.println("5.- Salir");
         Opcion = PideDato("Seleccione una opcion");

         if(Opcion.charAt(0) == '1') Escribe("Entero", fe);
         if(Opcion.charAt(0) == '2') Escribe("Flotante", ff);
         if(Opcion.charAt(0) == '3') Escribe("Cadena", fs);
         if(Opcion.charAt(0) == '4')
         {
	    se = new FileInputStream("Enteros.txt");
            sf = new FileInputStream("Flotantes.txt");
            ss = new FileInputStream("Cadenas.txt");
            Lee("Entero", se);
            Lee("Flotante", sf);
            Lee("Cadena", ss);
         };
         if(Opcion.charAt(0) == '5') return;
      }
   }

   public static void Escribe(String Mensaje, FileOutputStream FF)
   {
      byte[] buffer = new byte[81];
      int nbytes;

      try
      {
         System.out.println("Introduzca un " + Mensaje + ": ");
         nbytes = System.in.read(buffer);
         FF .write(buffer, 0, nbytes);
      }
      catch (IOException e){}
   }

   public static void Lee(String Mensaje, FileInputStream FF)
   {
      byte[] buffer = new byte[81];
      int nbytes;

      try
      {
         System.out.println("Lectura de " + Mensaje + ": ");
         nbytes = FF.read(buffer, 0, 81);
         String str = new String(buffer, 0, nbytes);
         System.out.println(str);
      }
      catch (IOException e){}
   }
}