Advertisement
Guest User

Shitcode

a guest
Oct 18th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.io.*;
  3. public class Homework6 {
  4.  
  5.  
  6.  
  7. public static void main(String[] args)throws IOException {
  8. Scanner scan = new Scanner(System.in);
  9. System.out.println("Please enter filename");
  10. String FileName = scan.next();
  11. System.out.println("Enter a word to check:");
  12. String str = scan.next();
  13. scanSTR(str, FileName);
  14. scan.close();
  15.  
  16. }
  17. public static void scanSTR(String str, String FileName) throws IOException{
  18. File inputFile = new File(FileName);
  19. Scanner in = new Scanner(inputFile);
  20. String verified = "";
  21. while (in.hasNext()) {
  22. String input = in.next();
  23. if (input.contains(str))
  24. verified += in.next();
  25. }
  26. System.out.println(verified);
  27. }
  28.  
  29.  
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement