package jp.co.dragonsoftit.d0001; import java.io.BufferedReader; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map.Entry; import java.util.Set; public class list { public static void main(String args[]){ //System.out.println("&&&&&&&&&&&"); hashentryset(); } public static void hashentryset(){ List<String> filecontent = new ArrayList<String>(); String contentstr =""; String userid=""; String username=""; //System.out.println("&&&&&&&&&&&"); HashMap<String,HashMap<String,Set<method>>> ht3 =new HashMap<String,HashMap<String,Set<method>>>(); HashMap<String,Set<method>> ht2 =new HashMap<String,Set<method>>(); Set<method> ht1 =null; method mthod = null; searcher.getInstance().iffind(); //for(int m=0;m<10;m++){ //ht3 =new HashMap<String,HashMap<String,Set<method>>>(); for(int k=0;k<10;k++){ ht2 =new HashMap<String,Set<method>>(); for(int j=0;j<10;j++){ ht1 =new HashSet<method>(); for(int i=0;i<10;i++){ mthod=new method(); mthod.setUserid("1001"+i); mthod.setUsername("cxl001"+i); ht1.add(mthod); } ht2.put("ht2"+j, ht1); } ht3.put("ht3"+k, ht2); } //} for(Entry<String,HashMap<String,Set<method>>> ht3sub:ht3.entrySet()){ String ht3key =ht3sub.getKey(); filecontent = new ArrayList<String>(); HashMap<String,Set<method>> ht3value =ht3sub.getValue(); for(Entry<String,Set<method>> ht2sub:ht3value.entrySet()){ String ht2key =ht2sub.getKey(); contentstr = "/""+ht3key+"."+ht2key+"/",/n"; filecontent.add(contentstr); Set<method> ht2value =ht2sub.getValue(); Iterator ite = ht2value.iterator(); while(ite.hasNext()){ //for(method mthd:ht2value){ method mtd =(method)ite.next(); userid =mtd.getUserid(); username =mtd.getUsername(); //filecontent = new ArrayList<String>(); filecontent.add("/"/","+"/""+userid+"::"+username+"/",/n"); //} } } createcsvfile("E:/document/1/"+"fname"+ht3key+".csv",filecontent); } } public static void createcsvfile(String filename,List filecontent){ File f = new File(filename); //BufferedReader br = new BufferedReader(f); FileWriter fw =null; try { fw =new FileWriter(f); for(int i=0;i<filecontent.size();i++){ fw.write((String)filecontent.get(i)); } //fw.write((String)filecontent.get(0)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ try{ fw.close(); } catch (IOException e) { } } } } class method{ private String userid; private String username; public String getUserid() { return userid; } public void setUserid(String userid) { this.userid = userid; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } }