Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException, ClassNotFoundException {
- File fichero = new File("C:\\Users\\usuario\\Desktop\\NuevaCarpeta\\cursos2.dat");
- FileInputStream filein = new FileInputStream(fichero);
- ObjectInputStream dataIS = new ObjectInputStream(filein);
- System.out.println("Comienza el proceso de creacion del fichero a XML...");
- //Creamos un objeto Lista de Personas
- ListaCursos lista = new ListaCursos();
- try {
- while(true) { //lectura del fichero
- Curso c = (Curso) dataIS.readObject();
- //añadir persona a la lista
- lista.add(c); //añadir persona a la lista
- }
- } catch (EOFException e) {}
- dataIS.close();
- try {
- XStream xstream = new XStream();
- //cambiar de nombre a las etiquetas XML
- xstream.toXML(lista, new FileOutputStream("C:\\Users\\usuario\\Desktop\\NuevaCarpeta\\cursos2.xml"));
- System.out.println("Creando fichero XML...");
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement