「java英文文档」java英文单词

博主:adminadmin 2022-11-27 07:48:05 50

本篇文章给大家谈谈java英文文档,以及java英文单词对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

java实现按词头、词尾提取英文文档中的单词的完整代码代码

public class Test {

public static void main(String[] args) {

Test t =new Test();

File file = new File("E:\\桌面\\words.txt");

try {

ListString list= t.getWords(file, true,"h");

for (String string : list) {

System.out.print(string+"   ");

}

} catch (Exception e) {

e.printStackTrace();

}

}

/**

 * java实现按词头、词尾提取英文文档中的单词

 * @param file 原文件

 * @param isHead 按词头true 按词尾false

 * @param fix 关键词

 * @return

 * @throws Exception 

 */

public ListString getWords(File file , boolean isHead,String fix) throws Exception{

//读取文件中的内容到字符串str

FileInputStream fis = new FileInputStream(file);

BufferedInputStream bis = new BufferedInputStream(fis);

int i=0;

String str = "";

while ((i=bis.read())!=-1) {

str+=(char)i;

}

System.out.println(str);

bis.close();

fis.close();

//将str分割为单词数组

String[] words = str.split(" ");

ListString list = new ArrayListString();

if (isHead) {

for (String word : words) {

if (word.startsWith(fix)) {

list.add(word);

}

}

}else {

for (String word : words) {

if (word.endsWith(fix)) {

list.add(word);

}

}

}

return list;

}

}

推荐一些简单的Java英文技术文档

首先,JAVA API肯定要的啦,百度搜索一下一箩筐,没有的话留下邮箱我发给你.

其次是介绍java类库里的类的使用方法的Sun_Java_Tutorial了,这个也很经典,应该不难找到.如果没有就留邮箱...

Thinking in java最好是入门了再看,不适合初学者...

Introduction.to.Java.Programming这本入门就非常不错...

java计算一篇英文文档词频 并按出现次数从高到低输出(以下基础上补充)谢谢!

String result = sb.toString();

String[] Str = result.split("[^A-Za-z0-9]"); //quanbu

for(String string:Str){

singleSet.add(string);

if("".equals(string)){ //这里是我加的,去除空格次数的处理

singleSet.remove("");

}

}

MapString, Integer map=new HashMapString, Integer();

for (String childString : singleSet){

int count=0;

for(String fatherString : Str){

if(fatherString.equals(childString)){

count++;

}

}

map.put(childString, count); //存储在hashmap中

}

ArrayListEntryString,Integer l = new ArrayListEntryString,Integer(map.entrySet());

Collections.sort(l, new ComparatorObject(){

public int compare(Object e1, Object e2){

int v1 = Integer.parseInt(((EntryString,Integer)e1).getValue().toString());

int v2 = Integer.parseInt(((Entry)e2).getValue().toString());

return v2-v1; //改为v1-v2就是从小到大了

}

});

for (EntryString, Integer e: l){

System.out.println(e.getKey()+" "+e.getValue());

}

代码仅供参考!希望对你有用

关于java英文文档和java英文单词的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-11-27,除非注明,否则均为首码项目网原创文章,转载请注明出处。