资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

单词簿java代码 java中英语单词

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

public class Test {

创新互联主要为客户提供服务项目涵盖了网页视觉设计、VI标志设计、营销推广、网站程序开发、HTML5响应式重庆网站建设手机网站制作设计、微商城、网站托管及网站维护、WEB系统开发、域名注册、国内外服务器租用、视频、平面设计、SEO优化排名。设计、前端、后端三个建站步骤的完善服务体系。一人跟踪测试的建站服务标准。已经为成都阳台护栏行业客户提供了网站开发服务。

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猜单词游戏的代码,要求如下

import java.util.Random;

import java.util.Scanner;

public class GuessString {

public static void main(String[] args){

String[] strings={"apple","orange","tom","kitty","hello","world","have","fun","hehe","ok"};

Random rand=new Random();

String choosed=strings[rand.nextInt()%10];

StringBuilder guessString=new StringBuilder(choosed);

StringBuilder sb=new StringBuilder();

for(int i=0;iguessString.length();i++)

sb.append("_ ");

System.out.println(sb);

Scanner scanner=new Scanner(System.in);

int numberGuessed=0;

while(numberGuessedguessString.length()){

char c=scanner.next().charAt(0);

int index=guessString.indexOf(c+"");

if(index=0){

if(sb.charAt(2*index)=='_'){

guessString.setCharAt(index, '*');

sb.setCharAt(index*2, c);

numberGuessed++;

}

}

System.out.println(sb);

}

}

}

简易电子词典 无需数据库 用map添加单词及含义的 java源代码

public class Test4 {

static MapString, String map = new TreeMapString, String();

static {

map.put("watermelon", "西瓜");

map.put("banana", "香蕉");

map.put("strawberry", "草莓");

map.put("apple", "苹果");

}

public static void main(String[] args) {

System.out.println("请输入单词");

Scanner sc = new Scanner(System.in);

while (sc.hasNext()) {

String str1 = sc.nextLine();

if(str1.equals("退出")){

return;

}

else if (map.containsKey(str1)) {

System.out.println(map.get(str1));

} else{

System.out.println("次单词为新词,添加意思");

Scanner sc1 = new Scanner(System.in);

String str2=sc1.nextLine();

map.put(str1, str2);

System.out.println("添加成功。");

}

}

}

}


文章名称:单词簿java代码 java中英语单词
网站链接:http://cdkjz.cn/article/dojggpp.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220