안녕하세요 제 질문은 열별로 텍스트 파일을 필터링하는 방법입니다. 행 사이의 범위에서 파일을 잘라 내고 싶습니다.내 파일에는 다음과 같은 종류의 데이터가 있습니다.
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;
사용자가 원본 파일에서 새로 생성 된 파일로 작성할 내용을 필터링 할 수 있기를 바랍니다.8935901990807474490에서 8935901990807474532까지의 예이며이 번호의 경우 시작 행과 마지막 행이이 범위에 있습니다.
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);
}
}