in C++ ¶
~cpp 
#include <fstream>
using namespace std;
int main()
{
	ifstream fin("input.txt"); // fin과 input.txt를 연결 
	ofstream fout("output.txt"); // fout과 output.txt를 연결
	int a,b;
	fin >> a >> b; // cin으로 화면에서 입력받는다면, fin은 연결된 파일로부터 입력받는다.
	fout << a+b << endl; // cout으로 화면으로 출력한다면, fout은 연결된 output.txt에 a+b를 출력
	return 0;
}
~cpp 3 8
Python ¶
~cpp 
fin = file('input.txt')
fout = file('output.txt.','w')
a,b=[int(i) for i in fin.read().split()]
print >> fout,(a+b) #혹은 fout.writeline( str(a+b)+'n' )
fin.close()
fout.close()
~cpp 3 8
Java ¶
~cpp 
try { 
String inputString; 
InputStreamReader isr = new InputStreamReader(new FileInputStream(fileName)); 
BufferedReader br = new BufferedReader(isr); 
while((inputString = br.readLine()) != null) { 
      buf = buf + inputString ; 
      buf = buf + "r" ; 
      buf = buf + "n" ; 
       {} br.close(); 
} 
catch (IOException e) 
 System.out.println("Error : "+ e.toString()); {}












