-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteExample.java
More file actions
27 lines (25 loc) ยท 810 Bytes
/
WriteExample.java
File metadata and controls
27 lines (25 loc) ยท 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package ch18.sec02.exam01;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
public class WriteExample {
public static void main(String[] args) {
String fileName = "temp/test1.db";
try {
OutputStream os = new FileOutputStream(fileName);
byte a = 10;
byte b = 20;
byte c = 30;
// 1 byte ์ฉ ์ถ๋ ฅ
os.write(a);
os.write(b);
os.write(c);
// ๋ด๋ถ ๋ฒํผ์ ์๋ฅํ๋ ๋ฐ์ดํธ๋ฅผ ์ถ๋ ฅํ๊ณ ๋ฒํผ๋ฅผ ๋น์
os.flush();
// ์ถ๋ ฅ ์คํธ๋ฆผ์ ๋ซ์ ์ฌ์ฉํ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ํด์
os.close();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}