Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1.  
  2. package fourletterwordpercent;
  3.  
  4. import java.io.File;
  5. import java.io.FileNotFoundException;
  6. import java.io.FileReader;
  7. import java.util.ArrayList;
  8. import java.util.Scanner;
  9.  
  10. /**
  11. *
  12. * @author Jacob Keenan
  13. */
  14. public class FourLetterWordPercent {
  15.  
  16. public static void main(String[] args) {
  17. System.out.println("Please enter the name of a text file.");
  18. ArrayList<String> words = new ArrayList<>();
  19. ArrayList<String> fourLetters = new ArrayList<>();
  20.  
  21. Scanner keyIn = new Scanner(System.in);
  22. String fileName = keyIn.next();
  23. File inputFile = new File(fileName + ".txt");
  24.  
  25. FileReader fr;
  26. try
  27. {
  28. Scanner list = new Scanner(inputFile);
  29. fr = new FileReader(inputFile);
  30. while (list.hasNext())
  31. {
  32. words.add(fileName);
  33. }
  34. System.out.println(words);
  35.  
  36. }
  37. catch (FileNotFoundException e)
  38. {
  39. System.out.println("Couldn't find that file. Sorry!");
  40. }
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement