2013-01-05 5 views
0

단순히 ArrayList를 XML 파일로 덤프 할 수 있습니까?arraylist를 XML 파일로 저장

다양한 유형의 메시지 객체를 포함하는 배열 목록이 있습니다.

로그를 유지하려면 XML 파일에 저장하십시오.

내가 시도한 것은 이것입니다.

public void saveConversation() 
    { 
     FileOutputStream f_out; 
     try { 
      f_out = new FileOutputStream("convo.txt"); 
      // Write object with ObjectOutputStream 
      ObjectOutputStream obj_out = new ObjectOutputStream (f_out); 
      // Write object out to disk 
      obj_out.writeObject (convo); 
     } catch (IOException ex) { 
      Logger.getLogger(HunterCom.class.getName()).log(Level.SEVERE, null, ex); 
     } 
    } 

작성된 파일은별로 영향을주지 않습니다. 이것을 읽을 수있는 XML로 바꿀 수있는 간단한 방법이 있는지 궁금합니다.

+2

도움이 될 수 있습니다. http://stackoverflow.com/questions/3024105/how-to-generate-xml-in-string-representation-in-java – bakkal

답변

0

XStream을 보면이 작업을 정확하게 수행 할 수 있습니다.

관련 문제