엔지니어가 되고 싶은 공돌이
01. File 본문
1. 1. a Physical File and a Logical File
- Physical File: 컴퓨터의 기억장치에 저장된 바이트들의 연속.
- Logical File: OS의 도움을 받아서 DB나 다른 데이터 구조에 저장된 가상의 파일.
- 동일한 데이터를 어떤 관점에서 보냐의 차이입니다. Physical은 파일매니저, Logical File은 Application.
1. 2. File I/O
- File을 여는 방법은 이미 존재하는 파일을 여는 방법과 새로운 파일을 생성하는 방법 2가지가 있습니다.
- File을 닫는 것은 그 파일을 기록하기 위해 사용했던 버퍼가 비워지고,
기록한 모든 것이 파일에 기록됨을 보장한다는 뜻입니다.
- C
fp = fopen(filename, mode);
fclose(fp);
- C++
#include<fstream>
using namespace std;
ifstream inStream; [Reading]
ofstream outStream; [Writing]
inStream.open(filename);
outStream.open(filename);
inStream.close();
outStream.close();
- Java
FileWriter fw = new FileWriter(filename);
FileReader fr = new FileReader(filename);
fw.close();
fr.close();
- Python
infile = open(filename, mode);
infile.close();
'Computer Science > File Structure' 카테고리의 다른 글
03. Computer Storage Devices (0) | 2025.02.14 |
---|---|
02. Hard Disk Drive (0) | 2025.02.14 |
Comments