ceshishuju2

 public static List getInstance(String path) throws Exception
 {
   
     xml = new ReadXML();
  File file = new File(path);
  if(file.isDirectory())
  {
   File[] fileList = file.listFiles();
   for(int i = 0 ; i < fileList.length ; i++)
   {
    File nodeFile = fileList[i];
    System.out.println(nodeFile);
    getInstance("00="+nodeFile.toString());
   }
  
  
  }
  else
  {
   String fileName = file.getName();
//   System.out.println(file.getPath());
   if(fileName.indexOf("zh") > 0)
   {
       list1 = getbuild(fileName);
   }
  }
 
  return list1;
 }
 static List list1 = new ArrayList();
 static List tagList = new ArrayList();
 static List zhList = new ArrayList();
 static List enList = new ArrayList();
 static List list = new ArrayList();
 public static List getbuild(String path) throws Exception
 {
 
//  InputStreamReader isr = new InputStreamReader(new FileInputStream(path));
   File file = new File(path);
   if(file.isDirectory())
   {
       File[] filelist =  file.listFiles();
       for(int i = 0; i < filelist.length; i++)
       {
           File fl = filelist[i];
           System.out.println("path=="+fl.getPath());
           getbuild(fl.getPath());
       }
   }
   else
   {
   File fi = new File(path);
   String name = fi.getName();
   if("resource_zh.xml".endsWith(name))
   {
   Reader isr = new InputStreamReader(new FileInputStream(path),"UTF-8");
  SAXBuilder build = new SAXBuilder();
   doc = build.build(isr);
   isr.close();
 
   Element root = doc.getRootElement();
   List<Element> elementlist  = root.getChildren();
   for(int i = 0; i < elementlist.size(); i++)
   {
    Element child = elementlist.get(i);
    Attribute id = child.getAttribute("id");
    String idCon = id.getValue();
    String con = child.getValue();
    tagList.add(idCon);
    zhList.add(con);
    System.out.println(child.getValue());
//    System.out.println(child.getAttributeValue("id"));
    System.out.println(idCon);
   }
   list.add(tagList);
   list.add(zhList);
   }
   }
   return list;
//  return xml;
 }

 

___________________________________读excel

Workbook  book = Workbook.getWorkbook(new File(excelName));

 Sheet sheet=book.getSheet(0); 

  Cell[] cell0 = sheet.getRow(0);

 int rowCount = sheet.getRows();

 

 for(int r=1; r < sheet.getRows(); r++)
                {      
                        Cell[] cell = sheet.getRow(r);  
                        if (cell.length > 1 && cell[0].getContents().length() != 0)
                        {
                            deptName = cell[0].getContents() == null ? "" : cell[0].getContents();  

 

你可能感兴趣的:(xml,Excel)