讀標籤文件,修改屬性值

           public static void setImagesDomain1() throws DocumentException, IOException{
               String str="D:/4.24/T00385101.html"; 
       
                org.jsoup.nodes.Document doc = Jsoup.parse(new File(str), "utf-8");
                Elements srcs = doc.select("link");
                for (Element element : srcs) {
                    if (element.attr("href")!=null) {
             element.attr("href","aaaaaaaa");
                    System.out.println(element.attr("href"));     
                    }
                }  

 

//搞了大半天,就糾結了這句話
                FileOutputStream fos = new FileOutputStream("D:/"+new File(str).getName(), true);
                fos.write(doc.toString().getBytes());
                fos.close();
                     
                
           }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章