1
1
package practice .io ;
2
2
3
- import java .io .*;
3
+ import java .io .BufferedReader ;
4
+ import java .io .IOException ;
5
+ import java .io .InputStreamReader ;
6
+ import java .io .PrintStream ;
7
+ import java .io .PrintWriter ;
4
8
5
9
public class MainClass {
6
10
7
11
public static void main (String [] args ) throws IOException {
8
12
9
- /*
10
13
String path = "E:\\ eclipse-workspace\\ Webtest\\ hello_world_copy.txt" ;
14
+ byte [] buffer = new byte [512 ];
15
+
16
+ // ---
17
+ /*
18
+ FileInputStream fis = new FileInputStream(path);
19
+ FileOutputStream fos = new FileOutputStream("copied.txt");
20
+
21
+ // read()가 argument를 받지 않으면 개별 문자의 byte를 반환한다
22
+ // int data = 0;
23
+ // while ( (data = fis.read()) != -1 ) {
24
+ // fos.write(data);
25
+
26
+ // read()가 argument를 받으면 argument의 length 내에서 총 몇 byte나 차지하는지를 반환한다
27
+ int dataCount = 0;
28
+ while ( (dataCount = fis.read(buffer)) != -1 ) {
29
+ fos.write(buffer, 0, dataCount);
30
+ }
31
+ fos.close();
32
+ fis.close();
33
+ */
34
+ // ---
35
+
36
+ PrintStream ps = System .out ;
37
+ PrintWriter pw2 = new PrintWriter (ps );
38
+ pw2 .println ("ddd" );
11
39
12
- FileLoader fl = new FileLoader("E:\\eclipse-workspace\\Webtest\\hello_world.txt");
13
- byte[] b = new byte[3];
40
+ // ---
41
+
42
+ BufferedReader br2 = new BufferedReader (new InputStreamReader (System .in ));
43
+ String str = br2 .readLine ();
44
+ System .out .println (str );
45
+
46
+ // pw2.close();
47
+ br2 .close ();
48
+
49
+ // ---
50
+ /*
51
+ FileLoaderClass fl = new FileLoaderClass("E:\\eclipse-workspace\\Webtest\\hello_world.txt");
14
52
15
53
fl.read();
16
54
17
55
// ---
18
56
19
- FileWriter fw = new FileWriter (path);
57
+ FileWriterClass fw = new FileWriterClass (path);
20
58
21
- fw.write("임세진!입니다. ");
59
+ fw.write("임세진!입니다");
22
60
23
61
// ---
24
62
@@ -45,6 +83,7 @@ public static void main(String[] args) throws IOException {
45
83
46
84
// ---
47
85
86
+ /*
48
87
String path_to_load = ".\\testFile.txt";
49
88
String path_to_save = ".\\testFile_copy.txt";
50
89
@@ -60,6 +99,7 @@ public static void main(String[] args) throws IOException {
60
99
File file = new File(".");
61
100
String absolutePath = file.getAbsolutePath();
62
101
System.out.println(absolutePath);
102
+ */
63
103
64
104
// ---
65
105
0 commit comments