forked from Vikram-12321/WordleApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwordbank.java
More file actions
48 lines (37 loc) · 1.34 KB
/
Copy pathwordbank.java
File metadata and controls
48 lines (37 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.Writer;
public class wordbank {
public static void createFile(String args[]) throws IOException {
Scanner scnr = new Scanner(new File("wordbank.txt"));
char letter = 'z';
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("letter_"+ letter + ".txt"), "utf-8"));
while(scnr.hasNextLine()) {
String word = scnr.nextLine();
if (word.charAt(0) == letter){
writer.write(word + "\n");
}
}
writer.close();
scnr.close();
}
public static boolean checkWord(String word) throws FileNotFoundException{
char letter = Character.toLowerCase(word.charAt(0));
Scanner txtscan = new Scanner(new File("Letters\\letter_"+ letter + ".txt"));
while(txtscan.hasNextLine()){
String str = txtscan.nextLine();
if(str.indexOf(word) != -1){
return true;
}
}
return false;
}
public static void main(String args[]) throws IOException {
System.out.println(checkWord("speak"));
}
}