Question
Writing a java program and I need it to search one text file,personnel_addresses2.txt for any any cities names that contain the word Wax and then
Writing a java program and I need it to search one text file,personnel_addresses2.txt for any any cities names that contain the word Wax and then take the names of the people that live in those cities and search for those names in another text file, personnel_salaries2.txt, but right now its only returning the first result when there should be 13,586. And also is this an efficient way to do this? If not can you show me a more efficient way please since the files have over 200,000 entries.
Code:
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.*; import java.util.*;
class A { public static void main(String[] args) throws IOException { File f1 =new File("personnel_addresses2.txt"); //Creation of File Descriptor for input file File f2 = new File("personnel_salaries2.txt"); String[] words = null; //Intialize the word Array String[] salary = null; List
for (String word : words) { if (word.equals(input)) //Search for the given word { //list.add(Name); while((d = b2r.readL System.out.println(name);ine()) != null) { salary = d.split("\\|"); Person = salary[0]; Sal = salary[1]; for (String sal : salary) { if(sal.equals(Name)) { System.out.println(d); } } }
} } } fr.close(); f2r.close();
personnel_addresses2.txt(partial)
Japheth Edwards|Albany Evan Taylor|Wax Olivia Grimme|Wax Alfonso McNeil|Somerset Allyson Schroeder|Washington April Tomes|Lancaster Laura Hancock|Louisville Robert Joyce|Remington HamedHaribHamed Yates|Somerset Robin Snoke|Remington David Bash|Versailles Boyko Michels|Washington
personnel_salaries2.txt(partial)
Jessica Collett|59789 Mitchell Long|68985 Khumbo Benedict|53385 Adam Kandibanda|67671 Lloyd Wathen|98564 Daniel Towery|36588 Suzanne Siferd|97528 James Gudger|67113
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started