質問編集履歴
3
title
CHANGED
File without changes
|
body
CHANGED
@@ -40,7 +40,7 @@
|
|
40
40
|
while((beanB = inputB.readBean("ファイルB")) != null){
|
41
41
|
if(key > beanB.getKey){
|
42
42
|
continue;
|
43
|
-
} else if(key
|
43
|
+
} else if(key < beanB.getKey) {
|
44
44
|
break;
|
45
45
|
} else if(key == beanB.getKey) {
|
46
46
|
beanA.setAAA(beanB.getAAA);
|
2
タブを修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -27,25 +27,26 @@
|
|
27
27
|
reader inputA = null;
|
28
28
|
reader inputB = null;
|
29
29
|
writer output = null;
|
30
|
+
|
30
31
|
BeanA beanA = null;
|
31
32
|
BeanB beanB = null;
|
32
33
|
|
33
34
|
// ファイルAの読込
|
34
35
|
while ((beanA = inputA.readBean("ファイルA")) != null){
|
35
|
-
|
36
|
+
Long key = beanA.getKey;
|
36
37
|
|
37
|
-
|
38
|
+
// ファイルBの読込
|
38
|
-
|
39
|
+
// ここで突合せを行うのですが、ファイルBの現在行をどう制御すべきなのかが、私には考え付きません
|
39
|
-
|
40
|
+
while((beanB = inputB.readBean("ファイルB")) != null){
|
40
|
-
|
41
|
+
if(key > beanB.getKey){
|
41
|
-
|
42
|
+
continue;
|
42
|
-
|
43
|
+
} else if(key > beanB.getKey) {
|
43
|
-
|
44
|
+
break;
|
44
|
-
|
45
|
+
} else if(key == beanB.getKey) {
|
45
|
-
|
46
|
+
beanA.setAAA(beanB.getAAA);
|
46
|
-
|
47
|
+
beanA.setBBB(beanB.getBBB);
|
47
|
-
|
48
|
+
break;
|
49
|
+
}
|
48
50
|
}
|
49
|
-
}
|
50
|
-
|
51
|
+
writer.writeBean(beanA);
|
51
52
|
}
|
1
ソースイメージを追記しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -18,4 +18,34 @@
|
|
18
18
|
|
19
19
|
※ファイルAのキーとマッチするレコードが、ファイルBに存在するとは限りません。逆もです。
|
20
20
|
|
21
|
-
自分で書いてみてもなかなか上手くいかないため、ここで質問させていただきました。
|
21
|
+
自分で書いてみてもなかなか上手くいかないため、ここで質問させていただきました。
|
22
|
+
|
23
|
+
--追記--
|
24
|
+
丸投げだとのご指摘があったので追記します。
|
25
|
+
(まだ丸投げだと言われれる気がしますが。。。)
|
26
|
+
// readerとwriterは独自クラスを用いています
|
27
|
+
reader inputA = null;
|
28
|
+
reader inputB = null;
|
29
|
+
writer output = null;
|
30
|
+
BeanA beanA = null;
|
31
|
+
BeanB beanB = null;
|
32
|
+
|
33
|
+
// ファイルAの読込
|
34
|
+
while ((beanA = inputA.readBean("ファイルA")) != null){
|
35
|
+
Long key = beanA.getKey;
|
36
|
+
|
37
|
+
// ファイルBの読込
|
38
|
+
// ここでファイルBとの突合せを行うのですが、現在行をどう制御すべきなのかが思いつきません
|
39
|
+
while((beanB = inputB.readBean("ファイルB")) != null){
|
40
|
+
if(key > beanB.getKey){
|
41
|
+
continue;
|
42
|
+
} else if(key > beanB.getKey) {
|
43
|
+
break;
|
44
|
+
} else if(key == beanB.getKey) {
|
45
|
+
beanA.setAAA(beanB.getAAA);
|
46
|
+
beanA.setBBB(beanB.getBBB);
|
47
|
+
break;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
writer.writeBean(beanA);
|
51
|
+
}
|