|
|
@ -0,0 +1,30 @@ |
|
|
|
package dam.com.es; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.ObjectOutputStream; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
public class EscribirFichObject { |
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException{ |
|
|
|
File fichero = new File("C:\\Users\\kevin\\Documents\\Actividad8_1\\FichPersona.dat"); |
|
|
|
|
|
|
|
FileOutputStream fileout = new FileOutputStream(fichero); |
|
|
|
ObjectOutputStream dataOS = new ObjectOutputStream(fileout); |
|
|
|
ArrayList<Persona> personas = new ArrayList<>(); |
|
|
|
|
|
|
|
String[] nombres= {"Paco","Pedro","Perico","Ivan"}; |
|
|
|
int[] edades= {32,43,66,98}; |
|
|
|
|
|
|
|
dataOS.writeObject(nombres); |
|
|
|
dataOS.writeObject(edades); |
|
|
|
|
|
|
|
dataOS .close(); |
|
|
|
dataOS .close(); |
|
|
|
|
|
|
|
System.out.println("Ha creado todos los datos y guardado en el archivo: " + fichero.getName() ); |
|
|
|
} |
|
|
|
|
|
|
|
} |