Pagini recente » Cod sursa (job #121226) | Cod sursa (job #1720662) | Cod sursa (job #966606) | Cod sursa (job #899850) | Cod sursa (job #1651357)
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;
public class Sum {
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(new FileReader("adunare.in.txt"));
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.txt");
fw.write(""+sum);
fw.close();
}
catch (FileNotFoundException e) {
System.out.println("File not Found!");
}
catch (IOException ex) {
Logger.getLogger(Sum.class.getName()).log(Level.SEVERE, null, ex);
}
}
}