공부기록

공부기록, 2021-06-16(java)

이재연 2021. 6. 16. 10:25

## java
- 파일 입출력
- 입력 :FileInputStream
```
try{
// 화면에 표시하고자 하는 파일을 선택한다.
File file = new File("절대경로");

// FileInputStream 는 File object를 생성자 인수로 받을 수 있다.
input = new FileInputStream(file);
int i = 0;
while((i = input.read()) != -1) {
System.out.write(i);
}
} catch (IOException e) {
System.out.println(e);
} finally {
try{
// 생성된 InputStream Object를 닫아준다.
input.close();
} catch(IOException io) {}
}
}
```
- 출력 : FileOutputStream
```
try{
// 복사할 대상 파일을 지정해준다.
File file = new File("절대경로");

// FileInputStream 는 File object를 생성자 인수로 받을 수 있다.
input = new FileInputStream(file);
// 복사된 파일의 위치를 지정해준다.
output = new FileOutputStream(new 절대경로"));

int readBuffer = 0;
byte [] buffer = new byte[512];
while((readBuffer = input.read(buffer)) != -1) {
output.write(buffer, 0, readBuffer);
}
System.out.println("파일이 복사되었습니다.");
} catch (IOException e) {
System.out.println(e);
} finally {
try{
// 생성된 InputStream Object를 닫아준다.
input.close();
// 생성된 OutputStream Object를 닫아준다.
output.close();
} catch(IOException io) {}
}

 

```
## 자주 하는 실수
- 기본기능으로 때우려고함
## 큐
- 어차피 헷갈리니 자주보고쓰자
## 내가 모르는 것
- 파일 입출력

## 일정
21-06-16
- 14:00 ~ 15:00 : 운동
- 15:00 ~ 16:00 : 운동
- 17:00 ~ 18:00 : 공부, 영상1업로드
- 18:00 ~ 19:00 : 공부, 영상2업로드
- 19:00 ~ 20:00 : 공부, 영상3업로드
- 20:00 ~ 21:00 : 공부
- 21:00 ~ 22:00 : 공부