package com.h3c.itac.util;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.junit.Test;
public class XMLAlter {
public static String readFileToString(String filePath) throws IOException{
String fileToString = FileUtils.readFileToString(new File(filePath));
return fileToString;
}
@Test
public void xmlAlter() throws IOException{
String string = readFileToString("jiaoben/docx/document.xml");
String replaceAll = string.replaceAll("<w:sz w:val=\"20\"/>", "<w:sz w:val=\"21\"/>");
FileUtils.writeStringToFile(new File("jiaoben/docx/document.xml"), replaceAll);
}
}