Java:OutputStream
De W3API
Contenido |
Descripcion
Clase que representa un stream de bytes de salida
Sintaxis
public abstract class OutputStream extends Object
Ejemplo
// Copiar ficheros
File origen = new File("origen.txt");
File destino = new File("destino.txt");
try {
InputStream in = new FileInputStream(origen);
OutputStream out = new FileOutputStream(destino);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
} catch (IOException ioe){
ioe.printStackTrace();
}