Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Anagram{
- public static void main(String[] args) throws IOException{
- Scanner fileScan = new Scanner(new FileInputStream("dictionary.txt"));
- String st;
- StringBuilder sb;
- DictInterface D = new MyDictionary();
- // Change MyDictionary() above to DLB() to test your DLB
- while (fileScan.hasNext())
- {
- st = fileScan.nextLine();
- D.add(st);
- }
- String filename = getFilename();
- File anagramData = new File(filename);
- Scanner inFile = new Scanner(anagramData);
- ArrayList<String> wordHolder = new ArrayList<String>();
- String tempWord = inFile.next();
- while(inFile.hasNext()){
- wordHolder.add(tempWord);
- }
- inFile.close();
- }
- public static String getFilename() throws FileNotFoundException {
- String filename = "";
- File confirm = new File(filename);
- boolean invalid = true;
- Scanner keyboard = new Scanner(System.in);
- do{
- System.out.print("Please enter the name of the inventory file: ");
- filename = keyboard.nextLine();
- confirm = new File(filename);
- if(!confirm.exists()){
- System.out.println("\nThe file does not exist or is invalid.");
- }
- else{
- invalid = false;
- }
- }while(invalid == true);
- return filename;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement