質問編集履歴
3
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,7 +82,7 @@
|
|
82
82
|
|
83
83
|
continue;
|
84
84
|
|
85
|
-
} else if(key
|
85
|
+
} else if(key < beanB.getKey) {
|
86
86
|
|
87
87
|
break;
|
88
88
|
|
2
タブを修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,6 +56,8 @@
|
|
56
56
|
|
57
57
|
writer output = null;
|
58
58
|
|
59
|
+
|
60
|
+
|
59
61
|
BeanA beanA = null;
|
60
62
|
|
61
63
|
BeanB beanB = null;
|
@@ -66,36 +68,36 @@
|
|
66
68
|
|
67
69
|
while ((beanA = inputA.readBean("ファイルA")) != null){
|
68
70
|
|
69
|
-
|
71
|
+
Long key = beanA.getKey;
|
70
72
|
|
71
73
|
|
72
74
|
|
73
|
-
|
75
|
+
// ファイルBの読込
|
74
76
|
|
75
|
-
|
77
|
+
// ここで突合せを行うのですが、ファイルBの現在行をどう制御すべきなのかが、私には考え付きません
|
76
78
|
|
77
|
-
|
79
|
+
while((beanB = inputB.readBean("ファイルB")) != null){
|
78
80
|
|
79
|
-
|
81
|
+
if(key > beanB.getKey){
|
80
82
|
|
81
|
-
|
83
|
+
continue;
|
82
84
|
|
83
|
-
} else if(key > beanB.getKey) {
|
85
|
+
} else if(key > beanB.getKey) {
|
84
86
|
|
85
|
-
|
87
|
+
break;
|
86
88
|
|
87
|
-
} else if(key == beanB.getKey) {
|
89
|
+
} else if(key == beanB.getKey) {
|
88
90
|
|
89
|
-
|
91
|
+
beanA.setAAA(beanB.getAAA);
|
90
92
|
|
91
|
-
|
93
|
+
beanA.setBBB(beanB.getBBB);
|
92
94
|
|
93
|
-
|
95
|
+
break;
|
96
|
+
|
97
|
+
}
|
94
98
|
|
95
99
|
}
|
96
100
|
|
97
|
-
}
|
98
|
-
|
99
|
-
|
101
|
+
writer.writeBean(beanA);
|
100
102
|
|
101
103
|
}
|
1
ソースイメージを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -39,3 +39,63 @@
|
|
39
39
|
|
40
40
|
|
41
41
|
自分で書いてみてもなかなか上手くいかないため、ここで質問させていただきました。
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
--追記--
|
46
|
+
|
47
|
+
丸投げだとのご指摘があったので追記します。
|
48
|
+
|
49
|
+
(まだ丸投げだと言われれる気がしますが。。。)
|
50
|
+
|
51
|
+
// readerとwriterは独自クラスを用いています
|
52
|
+
|
53
|
+
reader inputA = null;
|
54
|
+
|
55
|
+
reader inputB = null;
|
56
|
+
|
57
|
+
writer output = null;
|
58
|
+
|
59
|
+
BeanA beanA = null;
|
60
|
+
|
61
|
+
BeanB beanB = null;
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
// ファイルAの読込
|
66
|
+
|
67
|
+
while ((beanA = inputA.readBean("ファイルA")) != null){
|
68
|
+
|
69
|
+
Long key = beanA.getKey;
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
// ファイルBの読込
|
74
|
+
|
75
|
+
// ここでファイルBとの突合せを行うのですが、現在行をどう制御すべきなのかが思いつきません
|
76
|
+
|
77
|
+
while((beanB = inputB.readBean("ファイルB")) != null){
|
78
|
+
|
79
|
+
if(key > beanB.getKey){
|
80
|
+
|
81
|
+
continue;
|
82
|
+
|
83
|
+
} else if(key > beanB.getKey) {
|
84
|
+
|
85
|
+
break;
|
86
|
+
|
87
|
+
} else if(key == beanB.getKey) {
|
88
|
+
|
89
|
+
beanA.setAAA(beanB.getAAA);
|
90
|
+
|
91
|
+
beanA.setBBB(beanB.getBBB);
|
92
|
+
|
93
|
+
break;
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
writer.writeBean(beanA);
|
100
|
+
|
101
|
+
}
|