質問編集履歴
3
ドキュメント名の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -64,9 +64,9 @@
|
|
64
64
|
|
65
65
|
String name = System.getProperty("user.name");
|
66
66
|
|
67
|
-
File inFile = new File("C:\\Users\\" + name + "\\Documents\\NetBeansProjects\\amv-repo\\
|
67
|
+
File inFile = new File("C:\\Users\\" + name + "\\Documents\\NetBeansProjects\\amv-repo\\kako-aws-rest-dto\\src\\main\\java\\jp\\co\\sjnk\\kako\\aws\\dto\\customer\\" + inName + ".txt");
|
68
68
|
|
69
|
-
File outFile = new File("C:\\Users\\" + name + "\\Documents\\NetBeansProjects\\amv-repo\\
|
69
|
+
File outFile = new File("C:\\Users\\" + name + "\\Documents\\NetBeansProjects\\amv-repo\\kako-aws-rest-dto\\src\\main\\java\\jp\\co\\sjnk\\kako\\aws\\dto\\customer\\" + outName + ".txt");
|
70
70
|
|
71
71
|
try {
|
72
72
|
|
2
ソースコードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,3 +25,107 @@
|
|
25
25
|
どのようなメソッドが考えられますか?
|
26
26
|
|
27
27
|
どなたかご教授ください。
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
-----以下、書きかけのソースコード---------------------------------------------
|
32
|
+
|
33
|
+
import java.io.File;
|
34
|
+
|
35
|
+
import java.io.FileWriter;
|
36
|
+
|
37
|
+
import java.io.FileReader;
|
38
|
+
|
39
|
+
import java.nio.channels.*;
|
40
|
+
|
41
|
+
import java.io.BufferedReader;
|
42
|
+
|
43
|
+
import java.io.InputStreamReader;
|
44
|
+
|
45
|
+
import java.io.FileNotFoundException;
|
46
|
+
|
47
|
+
import java.io.IOException;
|
48
|
+
|
49
|
+
import java.io.FileInputStream;
|
50
|
+
|
51
|
+
import java.io.FileOutputStream;
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
class FileUtils {
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
public static void main(String args[]) {
|
60
|
+
|
61
|
+
String inName = "in";
|
62
|
+
|
63
|
+
String outName = "out";
|
64
|
+
|
65
|
+
String name = System.getProperty("user.name");
|
66
|
+
|
67
|
+
File inFile = new File("C:\\Users\\" + name + "\\Documents\\NetBeansProjects\\amv-repo\\mirai-aws-rest-dto\\src\\main\\java\\jp\\co\\sjnk\\mirai\\aws\\dto\\customer\\" + inName + ".txt");
|
68
|
+
|
69
|
+
File outFile = new File("C:\\Users\\" + name + "\\Documents\\NetBeansProjects\\amv-repo\\mirai-aws-rest-dto\\src\\main\\java\\jp\\co\\sjnk\\mirai\\aws\\dto\\customer\\" + outName + ".txt");
|
70
|
+
|
71
|
+
try {
|
72
|
+
|
73
|
+
FileUtils.copyFile(inFile, outFile);
|
74
|
+
|
75
|
+
FileUtils.deleteAnnotations(outFile);
|
76
|
+
|
77
|
+
} catch (IOException e) {
|
78
|
+
|
79
|
+
e.printStackTrace();
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
public static void copyFile(File in, File out) throws IOException {
|
88
|
+
|
89
|
+
FileChannel inChannel = new FileInputStream(in).getChannel();
|
90
|
+
|
91
|
+
FileChannel outChannel = new FileOutputStream(out).getChannel();
|
92
|
+
|
93
|
+
try {
|
94
|
+
|
95
|
+
inChannel.transferTo(0, inChannel.size(), outChannel);
|
96
|
+
|
97
|
+
} catch (IOException e) {
|
98
|
+
|
99
|
+
throw e;
|
100
|
+
|
101
|
+
} finally {
|
102
|
+
|
103
|
+
if (inChannel != null) {
|
104
|
+
|
105
|
+
inChannel.close();
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
if (outChannel != null) {
|
110
|
+
|
111
|
+
outChannel.close();
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
public static void deleteAnnotations(File out) throws IOException {
|
122
|
+
|
123
|
+
//TODO 「男」を含む行の削除
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
}
|
1
詳細の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,6 +12,16 @@
|
|
12
12
|
|
13
13
|
というメソッドを作成しています。
|
14
14
|
|
15
|
+
|
16
|
+
|
17
|
+
①は完了していますので、
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
・ファイルの変数を受取り、②の作業を完了したファイルを返すメソッド
|
22
|
+
|
23
|
+
を作成したいと考えています。
|
24
|
+
|
15
25
|
どのようなメソッドが考えられますか?
|
16
26
|
|
17
27
|
どなたかご教授ください。
|