早教吧作业答案频道 -->其他-->
java处理text文本求助,急,急,急.我有一个text文件,格式如下:汉字部分一asmuchaspossi-ble,tobebackwardcompati-blewithexistingwebbrowse-rs汉字部分二Thefollowingty-pographicalconventionsareusedinthisbook汉
题目详情
java 处理text文本求助,急,急,急.
我有一个text文件,格式如下:
汉字部分一 as much as possi-
ble,to be backward compati-
ble with existing webbrowse-
rs
汉字部分二 The following ty-
pographical conventions are
used in this book
汉字部分三 I have something
very similar in Midas 2.0
汉字部分四 I don’t much ca-
re about the parameter or t-
ag names
汉字部分五 It would be nice
if there was a way to spec-
ify the content type
...
需要写一段java文本处理代码,处理后原先的文本格式变为:
汉字部分一>> as much as possible,to be backward compatible with existing webbrowsers
汉字部分二>> The following typographical conventions are used in this book
汉字部分三>> I have something very similar in Midas 2.0
汉字部分四>> I don’t much care about the parameter or tag names
汉字部分五>> It would be nice if there was a way to specify the content type
...
也就是需要把汉字部分和英文用">>"隔开,同时使得英语部分处于一行.
由于text文件内容多,无法一一手工整理,
我有一个text文件,格式如下:
汉字部分一 as much as possi-
ble,to be backward compati-
ble with existing webbrowse-
rs
汉字部分二 The following ty-
pographical conventions are
used in this book
汉字部分三 I have something
very similar in Midas 2.0
汉字部分四 I don’t much ca-
re about the parameter or t-
ag names
汉字部分五 It would be nice
if there was a way to spec-
ify the content type
...
需要写一段java文本处理代码,处理后原先的文本格式变为:
汉字部分一>> as much as possible,to be backward compatible with existing webbrowsers
汉字部分二>> The following typographical conventions are used in this book
汉字部分三>> I have something very similar in Midas 2.0
汉字部分四>> I don’t much care about the parameter or tag names
汉字部分五>> It would be nice if there was a way to specify the content type
...
也就是需要把汉字部分和英文用">>"隔开,同时使得英语部分处于一行.
由于text文件内容多,无法一一手工整理,
▼优质解答
答案和解析
提供一个思路吧:
通过Reader(使用BufferedReader类好了)读取文件,每次读取一行,每一行返回的是一个String.
对每一个String遍历他的每一个字符,使用 正则表达式验证中文字符(中文的编码范围是:\u4e00-\u9fa5 ).
从中文到英文表示需要添加”>>“,中英文到中文表示需要换行.
按照这些规则写入一个新的文件就可以了.
通过Reader(使用BufferedReader类好了)读取文件,每次读取一行,每一行返回的是一个String.
对每一个String遍历他的每一个字符,使用 正则表达式验证中文字符(中文的编码范围是:\u4e00-\u9fa5 ).
从中文到英文表示需要添加”>>“,中英文到中文表示需要换行.
按照这些规则写入一个新的文件就可以了.
看了java处理text文本求助,...的网友还看了以下:
在matlab中 for i=1:2 T(i,:)=(t(i,:)for i=1:2 T(i,: 2020-05-13 …
在括号里填上所缺字母so()()erh()()t在括号里填上所缺字母so()()erh()()t从 2020-05-14 …
当时间由t=0增加到t=1时,人口增长了i%,由t=1增加到t=2时,人口增长了j%,这样,当时间 2020-05-14 …
1.The weather is _____()and windy.(提示:4个字母 第三个字母是 2020-05-16 …
but,so,if 都是连词,连接的句子在主句做的成分却不相同,怎么区分?如:I have mon 2020-05-16 …
I won't sleep until mother___(come)back I won't g 2020-05-17 …
Y=C+S+T怎么理解?我可以另外开贴,给50分Y=C+S+T怎么理解?我可以另外开贴,给50分支 2020-06-03 …
英语单词填空1.时间状语:d-r-n-2.场所:b-s-s-o-f-r--e-a-t-e-t3.教 2020-07-14 …
水平面上的平行导轨MN、PQ上放着两根导体棒ab、cd,两棒间用绝缘丝线系住.开始,匀强磁场垂直纸面 2020-12-25 …
在计算机国考2级C语言中,填空的中括号与分号有没有空格的要求???sum=0;sum+=t[i][i 2021-01-01 …