Cod sursa(job #1489223)

Utilizator George25Raduta George Cristian George25 Data 20 septembrie 2015 19:40:04
Problema A+B Scor 0
Compilator java Status done
Runda Arhiva de probleme Marime 1.03 kb
package ab;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;

class APlusB {

	public static void main(String[] args) {

		
		FileInputStream file;
		try {
			file = new FileInputStream("adunare.in");
		BufferedReader reader = new BufferedReader(new InputStreamReader(file));
		

		String line = reader.readLine();
		int total = 0;
		while (line != null) {
			total += Integer.parseInt(line);
			line = reader.readLine();
		}
//		System.out.println(total);
		file.close();
		FileOutputStream outFile = new FileOutputStream("adunare.out");
		byte[] contentInBytes = Integer.toString(total).getBytes();
		outFile.write(total);
		outFile.flush();
		outFile.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}