Pagini recente » Cod sursa (job #3180760) | Cod sursa (job #3191027) | Cod sursa (job #3181533) | Cod sursa (job #2916404) | Cod sursa (job #1069305)
/*
* 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 ab;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
/**
*
* @author Albert
*/
public class Ab {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
int a=0;
BufferedWriter out = new BufferedWriter(new FileWriter("adunare.out"));
BufferedReader br = new BufferedReader(new FileReader("adunare.in"));
try {
String line = br.readLine();
while (line != null) {
try
{
a+= Integer.parseInt(line);
}catch (NumberFormatException nfe) {
System.out.println("Input must be a number.");}
line = br.readLine();
}
} finally {
br.close();
}
out.write(String.valueOf(a));
out.close();
}
}