Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package tick;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.FileNotFoundException;
  5. import java.io.FileReader;
  6. import java.io.IOException;
  7. import java.util.ArrayList;
  8. import java.util.List;
  9.  
  10. public class TickFileReader {
  11.  
  12.     public static final String FILE_LOCATION = "./data/Info.txt";
  13.     public static List<String> list = new ArrayList<>();
  14.  
  15.     /**
  16.      * Reads tickfile data from <code>FILE_LOCATION</code>.
  17.      */
  18.     public static void readDataFromTxtFile() throws IOException {
  19.         try(BufferedReader br = new BufferedReader(new FileReader(FILE_LOCATION))){
  20.             String s;
  21.             while((s = br.readLine()) != null) {
  22.                 list.add(s);
  23.             }
  24.         }
  25.     }
  26.  
  27.     /*
  28.      * Search for a word in the txt file and do something with it.
  29.      */
  30.     public static void searchForWordInFile(final String WORD_SEARCHING_FOR) throws IOException {
  31.         try(BufferedReader br = new BufferedReader(new FileReader(FILE_LOCATION))) {
  32.             String s;
  33.             while((s = br.readLine()) != null) {
  34.                 if(WORD_SEARCHING_FOR.equals(s.trim())) {
  35.                     //found
  36.                 } else {
  37.                    
  38.                 }
  39.             }
  40.         }
  41.     }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement