Hello my question is how to filter text file by column, I mean that I want to cut file from range between rows. My files are with this kind of data:
284015160747447;8935901990807474474;
284015160747448;8935901990807474482;
284015160747449;8935901990807474490;
284015160747450;8935901990807474508;
284015160747451;8935901990807474516;
284015160747452;8935901990807474524;
284015160747453;8935901990807474532;
284015160747454;8935901990807474540;
284015160747455;8935901990807474557;
284015160747456;8935901990807474565;
284015160747457;8935901990807474573;
284015160747458;8935901990807474581;
284015160747459;8935901990807474599;
284015160747460;8935901990807474607;
284015160747461;8935901990807474615;
284015160747462;8935901990807474623;
284015160747463;8935901990807474631;
I want the user to be able to filter what to be written from the original file to the newly created: Example from 8935901990807474490 to 8935901990807474532, and for this number the start row and the last row to be in this range.
public class Test_read_file {
public static List<String> readFile() throws IOException {
try (BufferedReader br = new BufferedReader(new FileReader("C:\\\\\\\\Users\\\\\\\\Admin\\\\\\\\Desktop\\\\\\\\Work Files\\\\\\\\314-WO0000001133814\\\\\\\\Cards\\\\\\\\MBD10760_182.out"))) {
List<String> listOfData = new ArrayList<>();
String d;
while ((d = br.readLine()) != null) {
listOfData.add(d);
}
return listOfData;
}
}
public static void writeFile(List<String> listOfData) throws IOException {
try (BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\\\\\\\Users\\\\\\\\Admin\\\\\\\\Desktop\\\\\\\\Work Files\\\\\\\\314-WO0000001133814\\\\\\\\Cards\\\\\\\\MBD10760_187.out"))) {
for (String str : listOfData) {
bw.write(str);
bw.newLine();
}
}
}
public static void main(String[] args) throws IOException {
List<String> data = readFile();
writeFile(data);
}
}