取出数据写入xml,txt文件

public void getInfo(){
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		try{
		System.out.println("开始执行取数据操作!");
		List<Map<String,Object>> list = tdao.getInfo();
		 
		//FileWriter fileWriter = null;
		//fileWriter = new FileWriter("c:\\Result.txt");
		
		XMLEncoder encoder = null;
		FileOutputStream fos = null;
		fos = new FileOutputStream("c:\\shuting.xml"); 
		encoder = new XMLEncoder(fos); 
		for(int i = 0 ;i<list.size();i++){
			encoder.writeObject(list.get(i)); 
			//encoder.write(String.valueOf(list.get(i))+"===== ");
		}
		encoder.flush(); 
		encoder.close();
		//fileWriter.flush();
		//fileWriter.close();
		act.setOutData("list", list);
		}catch(Exception e){
			e.printStackTrace();
			act.setException(e);
		}

你可能感兴趣的:(取出数据写入xml,txt文件)