質問編集履歴
2
タイトル
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Java 出力のやり方について
|
test
CHANGED
File without changes
|
1
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,15 +46,13 @@
|
|
46
46
|
|
47
47
|
import java.io.BufferedWriter;
|
48
48
|
|
49
|
-
import java.io.File
|
49
|
+
import java.io.File;
|
50
50
|
|
51
|
+
import java.io.FileReader;
|
52
|
+
|
51
|
-
import java.io.File
|
53
|
+
import java.io.FileWriter;
|
52
54
|
|
53
55
|
import java.io.IOException;
|
54
|
-
|
55
|
-
import java.io.InputStreamReader;
|
56
|
-
|
57
|
-
import java.io.OutputStreamWriter;
|
58
56
|
|
59
57
|
|
60
58
|
|
@@ -62,45 +60,79 @@
|
|
62
60
|
|
63
61
|
|
64
62
|
|
65
|
-
public static void main(String[] args)
|
63
|
+
public static void main(String[] args) {
|
66
64
|
|
67
65
|
// TODO 自動生成されたメソッド・スタブ
|
68
66
|
|
69
67
|
|
70
68
|
|
71
|
-
|
69
|
+
//例外が発生しているかどうか調べる
|
72
70
|
|
73
|
-
new InputStreamReader(
|
74
|
-
|
75
|
-
new FileInputStream("C:\1.csv")));
|
76
|
-
|
77
|
-
BufferedWriter writer = new BufferedWriter(
|
78
|
-
|
79
|
-
new OutputStreamWriter(
|
80
|
-
|
81
|
-
new FileOutputStream("c:\2.csv"))))
|
82
|
-
|
83
|
-
|
71
|
+
try {
|
84
|
-
|
85
|
-
while ((line = reader.readLine()) != null) {
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
writer.write(line);
|
90
|
-
|
91
|
-
writer.newLine();
|
92
|
-
|
93
|
-
}
|
94
|
-
|
95
|
-
} catch (IOException e) {
|
96
|
-
|
97
|
-
e.printStackTrace();
|
98
|
-
|
99
|
-
}
|
100
72
|
|
101
73
|
|
102
74
|
|
75
|
+
File read = new File(new File(System.getProperty("user.home"), "Desktop"), "jusho.csv");
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
FileReader fr = new FileReader(read);
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
BufferedReader br = new BufferedReader(fr);
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
File file = new File("c:\practice\shain17.csv");
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
FileWriter fw = new FileWriter(file);
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
BufferedWriter bw = new BufferedWriter(fw);
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
String data;
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
while ((data = br.readLine()) != null) {
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
bw.write(data);
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
bw.newLine();
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
br.close();
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
bw.close();
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
} catch (IOException e) {
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
e.printStackTrace();
|
130
|
+
|
131
|
+
}
|
132
|
+
|
103
133
|
}
|
134
|
+
|
135
|
+
|
104
136
|
|
105
137
|
}
|
106
138
|
|