public?class?Test?{
創(chuàng)新互聯(lián)主要為客戶提供服務(wù)項(xiàng)目涵蓋了網(wǎng)頁(yè)視覺(jué)設(shè)計(jì)、VI標(biāo)志設(shè)計(jì)、營(yíng)銷推廣、網(wǎng)站程序開發(fā)、HTML5響應(yīng)式重慶網(wǎng)站建設(shè)、手機(jī)網(wǎng)站制作設(shè)計(jì)、微商城、網(wǎng)站托管及網(wǎng)站維護(hù)、WEB系統(tǒng)開發(fā)、域名注冊(cè)、國(guó)內(nèi)外服務(wù)器租用、視頻、平面設(shè)計(jì)、SEO優(yōu)化排名。設(shè)計(jì)、前端、后端三個(gè)建站步驟的完善服務(wù)體系。一人跟蹤測(cè)試的建站服務(wù)標(biāo)準(zhǔn)。已經(jīng)為成都陽(yáng)臺(tái)護(hù)欄行業(yè)客戶提供了網(wǎng)站開發(fā)服務(wù)。
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實(shí)現(xiàn)按詞頭、詞尾提取英文文檔中的單詞
?*?@param?file?原文件
?*?@param?isHead?按詞頭true?按詞尾false
?*?@param?fix?關(guān)鍵詞
?*?@return
?*?@throws?Exception?
?*/
public?ListString?getWords(File?file?,?boolean?isHead,String?fix)?throws?Exception{
//讀取文件中的內(nèi)容到字符串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分割為單詞數(shù)組
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("請(qǐng)輸入單詞");
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("添加成功。");
}
}
}
}