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
查看全文
相关阅读:
FastReport报表控件使用技巧总结
WinAPI: ShellExecute
Delphi Excel 操作大全
DATEADD和DATEDIFF函数、其他日期处理方法 、已打开的端口、FORMAT函数
javascript-时间戳
js-jquery-插件开发(二)【最终插件是最后一个,中间是过程】
js-jquery-插件开发(一)
Java-idea-eclipse-快捷键【mac,win】
Java-idea-生成for循环
Java-idea-设置类头注释和方法注释
原文地址:https://www.cnblogs.com/kingkoo/p/1134205.html
最新文章
gensim的word2vec如何得出词向量(python)
用gensim学习word2vec
ELMo解读(论文 + PyTorch源码)
NLP.TM | GloVe模型及其Python实现
Python3 try-except、raise和assert解析
http、TCP/IP协议与socket之间的区别
HTTP 协议简介
CoreData的数据迁移
CoreData学习-最好的一片文章
CoreData概略
热门文章
原 iOS面试题收集
IOS面试问题总结
IOS之分析网易新闻存储数据(CoreData的使用,增删改查)
SVN
iOS开发笔记--什么时候调用layoutSubviews
ExpressQuantumGrid4的cxGrid的一些使用方法和经验
Androd核心基础01
DELPHI XE5开发WEB服务器及安卓手机客户端
FastReport经验
FastReport中文网
Copyright © 2011-2022 走看看