Cod sursa(job #1651240)

Utilizator OvidiuDeliuDeliu Ovidiu-Marin OvidiuDeliu Data 12 martie 2016 20:09:22
Problema A+B Scor 0
Compilator java Status done
Runda Arhiva de probleme Marime 1.39 kb
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sum;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author DelOvi
 */
public class Sum {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        try {
        BufferedReader br = new BufferedReader(new FileReader("adunare.in"));
        int sum=0;
        String line;
        while((line=br.readLine())!=null){
        int x=Integer.parseInt(line);
        sum+=x;
        }
        br.close();

            FileWriter fw = new FileWriter("adunare.out");
            fw.write(sum);
            fw.close();
            }
        
        catch (FileNotFoundException e) {
                System.out.println("File not Found!");
            }
        catch(NumberFormatException e){
                    System.out.println("Exception at conversion String-");
                }
        catch (IOException ex) {
            Logger.getLogger(Sum.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
    }
    
}