Pagini recente » Cod sursa (job #1407883) | Cod sursa (job #2113028) | Cod sursa (job #3032637) | Cod sursa (job #2892582) | Cod sursa (job #1458665)
package ab;
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 Ab {
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();
}
}
}