bread, coffee and coding
FileInputStream과 FileOutputStream(Java) 본문
import java.io.*;
public class FileStreamTest {
public static void main(String[] args) throws IOException {
FileInputStream in = null;
FileOutputStream out = null;
try {
int c;
out = new FileOutputStream("data.txt", false);
for(int i=0;i <10; i++) {
out.write(i);
}
in = new FileInputStream("data.txt");
while ((c = in.read()) != -1) {
System.out.print(c+" ");
}
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
}

'Coding test' 카테고리의 다른 글
| Design patterns quiz (0) | 2021.07.14 |
|---|---|
| [Java] 성적을 배열에 넣고 총합과 평균을 출력해 봅시다 (0) | 2021.07.06 |
| 프로그래머스 1단계 짝수와 홀수(C#) (0) | 2021.07.05 |
| 프로그래머스 1단계 평균 구하기(C#) (0) | 2021.07.05 |
| 프로그래머스 1단계 직사각형 별찍기(C#) (0) | 2021.07.05 |