Pagini recente » Cod sursa (job #1341077) | Cod sursa (job #3178612) | Cod sursa (job #2357080) | Cod sursa (job #2724118) | Cod sursa (job #1458685)
package test;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class Test {
static int sum(int a,int b){
return a+b;
}
public static void main(String[] args) throws FileNotFoundException, IOException {
Scanner scanner = new Scanner(new FileReader(new File("adunare.in")));
int a,b;
a = scanner.nextInt();
b = scanner.nextInt();
try {
File file = new File("adunare.out");
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write(Integer.toString(sum(a,b)));
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}