InputStream과 OutputStream보다 편리하게 사용할수 있는 클래스이다.
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
InputStream is = null;
DataInputStream dis = null;
OutputStream os = null;
DataOutputStream dos = null;
try{
is = new FileInputStream("C:\\aaa\\bbb\\ccc.txt");
// dis가 is의 데이터를 받는다.
dis = new DataInputStream(is);
String str = dis.readUTF();
os = new FileOutputStream("C:\\aaa\\bbb\\ccc.txt");
dos = new DataOutputStream(os);
dos.writeUTF(str);
} catch (Exception e) {
} finally {
if(dos != null) {
try{
dos.close();
} catch (Exception e2) {
}
}
if(os != null) {
try{
os.close();
} catch (Exception e2) {
}
}
if(dis != null) {
try{
dis.close();
} catch (Exception e2) {
}
}
if(is != null) {
try{
is.close();
} catch (Exception e2) {
}
}
}
| cs |
댓글
댓글 쓰기