Ola galera estou com um erro no meu metodo de abrir xml gostaria que alguem me ajudasse pois nao estou intendendo prq esta dando o erro, ele cria o arquivo xml no diretorio mas esta com um erro no metodo abrirXml
package arquivos;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.rmi.UnmarshalException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
public class Metodos {
public void criarXml() {
Xml arquivo = new Xml();
//set nome, telefone
arquivo.setNome("Marcos");
arquivo.setTelefone(222);
//tratamento de erro
try {
// class que passa as informaçoes de objeto para xml
JAXBContext context = JAXBContext.newInstance(Xml.class);
// cria o xml
Marshaller marshal = context.createMarshaller();
marshal.marshal(arquivo, System.out);
System.out.println("");
System.out.println("Arquivo criado com Sucesso!!");
try{
//criando xml dentro de um arquivo
FileWriter file = new FileWriter("c:\\Agenda.xml");
//copia dentro do arquivo
marshal.marshal(arquivo, file);
}catch(IOException e){
System.out.println(e);
}
} catch ( Exception erro) {
System.out.println(erro);
}
}
public String abrirXml(String fileXml) {
JAXBContext context = null;
Unmarshaller unmarshaller = null;
try {
context = JAXBContext.newInstance(fileXml);
unmarshaller = context.createUnmarshaller();
return UnmarshalException.unmarshal(new FileInputStream(fileXml));
} catch (JAXBException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return null;
}
}
ai esta o codigo alguem pode me ajudar??