// Se le'e una l'inea y se escribe una l'inea
// usando un flujo de bytes.
import java.io.*;
public class Arch_demo_1
{
PrintStream PS = null; // Referencia al flujo de salida est'andar
InputStream IS = null; // Referencia al flujo de entrada est'andar
Arch_demo_1()
{
PS = System.out;
IS = System.in;
Escribe("Arch_demo_1.txt");
Lee("Arch_demo_1.txt");
}
public static void main(String args[]) throws IOException { new Arch_demo_1(); }
public void Escribe(String ARCHIVO)
{
byte[] buffer = new byte[81];
int nbytes;
try
{
FileOutputStream FOS = new FileOutputStream(ARCHIVO); // flujo de salida de bytes
PS.println("Dato: ");
nbytes = IS.read(buffer);
FOS.write(buffer, 0, nbytes);
} catch (IOException e){}
}
public void Lee(String Nombre)
{
byte[] buffer = new byte[81];
int nbytes;
try
{
FileInputStream FIS = new FileInputStream (Nombre); // flujo de entrada de bytes
PS.println("Lectura: ");
nbytes = FIS.read(buffer, 0, 81);
PS.println(new String(buffer, 0, nbytes));
} catch (IOException e){}
}
}