大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
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;
}
}
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);
}
}
}
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("添加成功。");
}
}
}
}