質問編集履歴
4
現状のコード記載
test
CHANGED
File without changes
|
test
CHANGED
@@ -137,3 +137,115 @@
|
|
137
137
|
}
|
138
138
|
|
139
139
|
```
|
140
|
+
|
141
|
+
### 【追記】現状のコード
|
142
|
+
|
143
|
+
```JAVA
|
144
|
+
|
145
|
+
package jp.aast.kyoiku;
|
146
|
+
|
147
|
+
import java.io.BufferedReader;
|
148
|
+
|
149
|
+
import java.io.BufferedWriter;
|
150
|
+
|
151
|
+
import java.io.FileInputStream;
|
152
|
+
|
153
|
+
import java.io.FileOutputStream;
|
154
|
+
|
155
|
+
import java.io.InputStreamReader;
|
156
|
+
|
157
|
+
import java.io.OutputStreamWriter;
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
public class CsvToText {
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
public static void main(final String args[]) {
|
168
|
+
|
169
|
+
try (
|
170
|
+
|
171
|
+
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
172
|
+
|
173
|
+
new FileInputStream(args[0]), "Windows-31J"));
|
174
|
+
|
175
|
+
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
|
176
|
+
|
177
|
+
new FileOutputStream(args[1]), "Windows-31J"))) {
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
while (reader.ready()) {
|
182
|
+
|
183
|
+
//入力ファイルから1行読み込む。
|
184
|
+
|
185
|
+
final String line = reader.readLine();
|
186
|
+
|
187
|
+
final FileOutputStream os = new FileOutputStream(args[1]);
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
final String enc = "Windows-31J";
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
final String[] items = line.replace("\"", "").split(",");
|
196
|
+
|
197
|
+
//行データを出力ファイルへ書き出す。
|
198
|
+
|
199
|
+
os.write(String.format("%010d", Integer.parseInt(items[0])).getBytes(enc));
|
200
|
+
|
201
|
+
os.write(String.format("%-100s", items[1]).getBytes(enc), 0, 20);
|
202
|
+
|
203
|
+
os.write(String.format("%-100s", items[2]).getBytes(enc), 0, 8);
|
204
|
+
|
205
|
+
os.write(String.format("%-100s", items[3]).getBytes(enc), 0, 8);
|
206
|
+
|
207
|
+
os.write(String.format("%-100s", items[4]).getBytes(enc), 0, 20);
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
os.close();
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
} catch (Exception e) {
|
220
|
+
|
221
|
+
e.printStackTrace();
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
System.out.println("異常終了しました。");
|
226
|
+
|
227
|
+
System.exit(-1);
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
System.out.println("正常終了しました。");
|
234
|
+
|
235
|
+
System.exit(0);
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
```
|
3
初心者アイコン表示
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,8 +7,6 @@
|
|
7
7
|
"1","コンビニ","100-0000","東京都","Aビル2階"
|
8
8
|
|
9
9
|
```
|
10
|
-
|
11
|
-
|
12
10
|
|
13
11
|
|
14
12
|
|
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -60,7 +60,7 @@
|
|
60
60
|
|
61
61
|
```JAVA
|
62
62
|
|
63
|
-
public class Csv
|
63
|
+
public class Csv {
|
64
64
|
|
65
65
|
|
66
66
|
|
1
書式の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,15 +36,7 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
0000000001
|
40
|
-
|
41
|
-
コンビニ□□□□□□
|
42
|
-
|
43
|
-
100-0000
|
44
|
-
|
45
|
-
東京都□
|
46
|
-
|
47
|
-
Aビル2階□□□□□␣
|
39
|
+
0000000001コンビニ□□□□□□100-0000東京都□Aビル2階□□□□□␣
|
48
40
|
|
49
41
|
|
50
42
|
|