zoukankan
html css js c++ java
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:/Html2.txt
"
));
//
转成后放到此文件
while
((strCurrentLine
=
BRead.readLine())
!=
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();
BWriter.newLine();
}
BRead.close();
BWriter.close();
}
catch
(FileNotFoundException e)
{
e.printStackTrace();
}
}
}
千人.NET交流群:18362376,因为有你,代码变得更简单,加群请输入cnblogs
查看全文
相关阅读:
成功解决vc6.0智能提示消失的BUG
如何在vc6,vc7,vc8下编译x264
Visual C++ 操作MS Offfice 控件
在英文版Visual Studion 2005 professional 中使用 Windows Mobile 2003 SE中文模拟器
x264 20060731 svn 版的编码移植
泛型算法:Tips
05年度EmilMatthew’s Blog文档整理
常用软件滤波方法及其示例程序
windows server 2003 配置
TI C64X 视频处理应用编程重点内容提示
原文地址:https://www.cnblogs.com/kingkoo/p/1134205.html
最新文章
区分 微软的众多手机开发版本
Hermite插值法
曲线拟合与插值
CString 操作指南
VS 2005 IDE 经典设置
[翻译]抓屏的各种方法
c 语言的宏定义
基于MMX指令集的程序设计简介
基于SSE指令集的程序设计简介
整理了一些tsql技巧
热门文章
Visual C++ MFC 简明教程
AEC (Acoustic Echo Canceller) 回音消除初探
C语言与C++不同之函数定义
常用的VOIP资源
语音编码
VC中一些控件的小技巧
DLL(Dynamic Link Libraries)专题
UTF8 and Unicode FAQ
vc数据类型转换大全
ffmpeg 的编译
Copyright © 2011-2022 走看看