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
查看全文
相关阅读:
Xamarin.Forms之Resx
Xamarin.Forms之OnElementPropertyChanged那些事
Xamarin.Android之Application的使用
Xamarin.Forms之FluentValidation(Model验证)
Xamarin.Forms如何为View添加背景色
odoo server命令行以及配置文件
ODOO的命令行调用以及config默认值
发掘odoo.cli.server.Server的秘密,OpenERP的第三根线头儿
odoo.cli.main()做了什么?
odoo.cli.main()指的是哪里?OpenERP的第二根线头儿
原文地址:https://www.cnblogs.com/kingkoo/p/1134205.html
最新文章
[转载]为什么说要远离“穷人”?
[转载]为什么说要远离“穷人”?
[转载]年薪10w和年薪100w的人,差在哪里?
[转载]年薪10w和年薪100w的人,差在哪里?
数据库访问性能优化(三)
数据库访问性能优化(三)
数据库访问性能优化(二)
数据库访问性能优化(二)
数据库访问性能优化(一)
rabbitmq升级新版本后,需要新建用户。新版本默认禁止别的机器用guest用户访问。
热门文章
g++ -g -o testboost testboost.cpp
ubuntu 重定向 会产生新的进程。
+p解决vim粘贴自动缩进。 数字gg跳到vim指定行。 vim查找到后,enter键修改
g++ -std=c++11 -g -o test emit_log_direct.cpp
解决FileExplorer窗口变小问题
Xamarin.Android之绑定库集合
Enum的规则
Xamarin.Android之Picker控件关闭可编辑状态
Xamarin莫名奇妙的BUG
Xamarin.Android绑定时Generator.exe报错
Copyright © 2011-2022 走看看