SHARE
TWEET

ej19

a guest Oct 23rd, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException, ClassNotFoundException {
  2.        
  3.        File fichero = new File("C:\\Users\\usuario\\Desktop\\NuevaCarpeta\\cursos2.dat");
  4.         FileInputStream filein = new FileInputStream(fichero);
  5.         ObjectInputStream dataIS = new ObjectInputStream(filein);
  6.         System.out.println("Comienza el proceso de creacion del fichero a XML...");
  7.  
  8.         //Creamos un objeto Lista de Personas
  9.         ListaCursos lista = new ListaCursos();
  10.  
  11.         try {
  12.             while(true) { //lectura del fichero
  13.             Curso c = (Curso) dataIS.readObject();
  14.  //añadir persona a la lista
  15.             lista.add(c); //añadir persona a la lista
  16.             }
  17.         } catch (EOFException e) {}
  18.                 dataIS.close();
  19.  
  20.         try {
  21.             XStream xstream = new XStream();
  22.             //cambiar de nombre a las etiquetas XML
  23.  
  24.             xstream.toXML(lista, new FileOutputStream("C:\\Users\\usuario\\Desktop\\NuevaCarpeta\\cursos2.xml"));
  25.             System.out.println("Creando fichero XML...");
  26.         } catch(Exception e) {
  27.                 e.printStackTrace();
  28.         }
  29.     }
  30.        
  31.        
  32.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top