Pagini recente » Cod sursa (job #2353245) | Cod sursa (job #1542137) | Cod sursa (job #775871) | Cod sursa (job #152288) | Cod sursa (job #2195028)
import java.io.BufferedReader;
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.io.Reader;
import java.util.Scanner;
public class Main {
static File f;
static File c;
public static void main(String[] args) throws IOException {
f = new File("C:\\Users\\Raul\\Desktop\\in.txt");
c = new File("C:\\Users\\Raul\\Desktop\\out.txt");
try {
BufferedReader in = new BufferedReader(new FileReader(f));
try {
String a = in.readLine();
int a1 = Integer.parseInt(a);
a=in.readLine();
int b = Integer.parseInt(a);
System.out.println(a1);
System.out.println(b);
BufferedWriter w = new BufferedWriter(new FileWriter(c));
int sum = a1 + b;
w.write(""+sum);
w.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}