Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tick;
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.List;
- public class TickFileReader {
- public static final String FILE_LOCATION = "./data/Info.txt";
- public static List<String> list = new ArrayList<>();
- /**
- * Reads tickfile data from <code>FILE_LOCATION</code>.
- */
- public static void readDataFromTxtFile() throws IOException {
- try(BufferedReader br = new BufferedReader(new FileReader(FILE_LOCATION))){
- String s;
- while((s = br.readLine()) != null) {
- list.add(s);
- }
- }
- }
- /*
- * Search for a word in the txt file and do something with it.
- */
- public static void searchForWordInFile(final String WORD_SEARCHING_FOR) throws IOException {
- try(BufferedReader br = new BufferedReader(new FileReader(FILE_LOCATION))) {
- String s;
- while((s = br.readLine()) != null) {
- if(WORD_SEARCHING_FOR.equals(s.trim())) {
- //found
- } else {
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement