두 개의 파일에 두 개의 파일이 있습니다.이 두 파일은 두 개의 별도 ArrayList<String>
컨테이너에 정보를 추가합니다. 아래의 '결과 파일/배열 목록'을 반영하는 최종 컨테이너 "finalPNList
"을 만들려고합니다.2 줄로 파일을 파싱하지 않아야하고 중복이 필요하지 않습니다. (특별한 경우)
문제는 중복을 피할 수 없다는 점입니다. 코드를 여러 가지 방법으로 변경하지 않고 성공했습니다. 때로는 조건을 너무 많이 제한하고 모든 중복을 피하고 때때로 너무 느슨하게두고 모든 중복을 포함합니다. 나는 그것을 올바르게 만드는 조건을 찾을 수없는 것 같습니다. 당신이 여기에 2 ArrayLists<String>
public static Map<String, List<String>> masterList = new HashMap<String, List<String>>();
public static List<String> finalPNList = new ArrayList<String>();
public static List<String> modifier = new ArrayList<String>();
public static List<String> skipped = new ArrayList<String>();
for (Entry<String, String> e : tab1.entrySet()) {
String key = e.getKey();
String val = e.getValue();
// returns BufferedReader to start line processing
inputStream = getFileHandle(val);
// builds masterList containing all data
masterList.put(key, processLine(inputStream));
}
for (Entry<String, List<String>> e : masterList.entrySet()) {
String key = e.getKey();
List<String> val = e.getValue();
System.out.println(modifier.size());
for (String s : val) {
if (modifier.size() == 0)
finalPNList.add(s);
if (!modifier.isEmpty() && finalPNList.contains(s)
&& !modifier.contains(key)) {
// s has been added by parent process so SKIP!
skipped.add(s);
} else
finalPNList.add(s);
}
modifier.add(key);
}
와지도를 받고 있다는 것을 무엇을 알고, processLine()
의 내용을보고, 정말 관련이 경우 ins't - 여기
파일 검색
012 3,516,123;data 123;data 456,data
파일 B
123;data 789,data 789,data
결과 파일/ArrayList를
123;data 123;data 789,data 789,data
예상되는 결과는 무엇입니까? –
내가 예상 한 출력물은 내 게시물의 결과 파일 섹션에 있습니다 ... 마지막 부분 –
중복 처리 방법에 대한 규칙을 좀 더 자세히 설명해 주시겠습니까? 위의 예에서 아직 명확하지 않습니다. – Meesh