0
I have a java xml reading exercise. My teacher indicated using the Xstream library and I’m not getting it. I read about the documentation, but I can’t identify the problem. I have the Transaction class with all variables and their gets and sets. I use the same class to do with a json using Gson and it works normally. the Main:
{
import java.io.File;
import com.thoughtworks.xstream.XStream;
public static void main(String[] args){
File remessajson = new File("C:remessa.xml");
System.out.println(remessajson.exists());
XStream xs = new XStream();
String xml = xs.toXML(remessajson);
Transacao a = (Transacao)xs.fromXML(xml);
System.out.println(a.getBancoPag());
}
Is presenting the error:
Security framework of XStream not initialized, XStream is probably vulnerable. Exception in thread "main" java.lang.ClassCastException: java.io.File cannot be cast to pack.Transacao at pack.Main.main(Main.java:19) true
The first xml items:
<list>
<br.com.pageseguro.RemessaCartaoCredito>
<nome>Adelaide Carvalhaes</nome>
<CPF>56608514522</CPF>
<bancoRecebimento>Caixa Econômica</bancoRecebimento>
<bancoPagamento>Banco Safra</bancoPagamento>
<data>2018-09-02 02:58:10.96 UTC</data>
<valor>362.4101749037519</valor>
<numeroCartao>98315792</numeroCartao>
<nomeTitular>LIEDSON LAGO</nomeTitular>
<parcelas>2</parcelas>
</br.com.pageseguro.RemessaCartaoCredito>
<br.com.pageseguro.RemessaCartaoCredito>
<nome>Viriato Ayres</nome>
<CPF>41057727598</CPF>
<bancoRecebimento>Banco do Brasil</bancoRecebimento>
<bancoPagamento>Banco do Brasil</bancoPagamento>
<data>2018-09-02 02:58:10.96 UTC</data>
<valor>475.60665046855246</valor>
<numeroCartao>92579840</numeroCartao>
<nomeTitular>VIRIATO AYRES</nomeTitular>
<parcelas>6</parcelas>
</br.com.pageseguro.RemessaCartaoCredito>......
Man, sorry it took so long. But it worked that way anyway. I had done another one, but with your suggestion it got easier. Thanks bro.
– Joe Reis