HTML中字符⼤⼩写转换(java)import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* 将HTML中<  >中的字母⼤⼩写进⾏转换
* @author
*
*/
public class ExchangeCase{
public static void main(String args[]) throws IOException{
boolean aFlg = false;//判斷"<>"⽤;
int intCount = 0;//计算"<>"⽤;
int intLine=0;//⾏数
String strCurrentLine=null;//当前⾏
String []dataSave = new String[10000];//将读到的每⼀⾏放进⼀个数组
try {
BufferedReader BRead = new BufferedReader(new InputStreamReader(
new FileInputStream("C:/Html.html") ));//读取⽂件
BufferedWriter BWriter=new BufferedWriter(new FileWriter("C:/"));//转成后放到此⽂件
while((adLine())!=null){
dataSave[intLine]=strCurrentLine;
intLine=intLine+1;
}
//System.out.println("総⾏数="+intLine);
for(int i=0; i<intLine;i++){
aFlg = false;
intCount = 0;
for (int j = 0; j < dataSave[i].length(); j++) {
char cByte = dataSave[i].charAt(j);
if (cByte == '<' && intCount == 0) {
aFlg = true;
}
if (cByte == '<') {
++intCount;
}
if (cByte == '>') {
--intCount;
}
if (cByte == '>' && intCount == 0) {
aFlg = false;
}
if (aFlg && intCount > 0) {
//转成⼩写
if (cByte >= 'A' && cByte <= 'Z') {    //⼤写: cByte >= 'a' && cByte <= 'z'
cByte += 32;                            //⼤写: cByte -= 32;
// System.out.print(cByte);
BWriter.write(cByte);
continue;
} else {
// System.out.print(cByte);
BWriter.write(cByte);
continue;
}
}
// System.out.print(cByte);
BWriter.write(cByte);
}
// System.out.println();
}
BRead.close();
BWriter.close();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
}pdf转html
}