Subido por er magodeoz

resume io

Anuncio
Destino: fichero binario
FileOutputStream fos = new FileOutputStream(“fichero.dat”);
PrintWriter pr = new PrintWriter(fos);
…
pr.println(“Escribimos texto”);
Destino: fichero texto
FileWriter fw = new FileWriter(“fichero.txt”);
PrintWriter pr = new PrintWriter(fw);
…
pr.println(“Escribimos texto”);
Origen: fichero binario
Se leen líneas
FileInputStream fis = new FileInputStream(“fichero.dat”);
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader buffer = new BufferedReader(isr);
…
String linea = buffer.readLine();
Origen: fichero texto
Se leen caracteres
FileReader fr = new FileReader(“fichero.txt”);
…
caracter = fr.read();
Origen: fichero texto
Se leen líneas
FileReader fr = new FileReader(“fichero.txt”);
BufferedReader buffer = new BufferedReader(fr);
…
String linea = buffer.readLine();
Destino: fichero binario
Se escriben datos con tipo
FileOutputStream fos = new FileOutputStream("salida.dat");
DataOutputStream dos = new DataOutputStream(fos);
…
dos.writeInt(5);
Origen: fichero binario
Se leen datos con tipo
FileInputStream fis = new FileInputStream("salida.dat");
DataInputStream dis = new DataInputStream(fis);
…
int entero = dis.readInt();
Origen: teclado (binario)
Se leen líneas
BufferedReader teclado = new BufferedReader(new InputStreamReader(System.in));
…
String entrada = teclado.readLine();
PrintWriter
FileOutputStream
DataOutputStream
FileWriter
print(…)
println(…)
write(String)
write(char[])
write(int)
write(byte[])
writeBoolean
writeChar
writeByte
writeShort
writeInt
writeLong
writeFloat
writeDouble
writeUTF
write(int)
write(char[])
write(String)
BufferedReader
InputStreamReader
FileInputStream
DataInputStream
FileReader
String readLine()
int read()
read(char[])
int read()
read(byte[])
readBoolean
readChar
readByte
readShort
readInt
readLong
readFloat
readDouble
readUTF
int read()
read(char[])
Descargar