Created
June 27, 2018 01:59
-
-
Save shalk/c84f1a2f599cc35557becb1c4a3c9f5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
public class Add { | |
public static void main(String[] args) throws IOException { | |
BufferedReader reader1 = new BufferedReader(new FileReader("1.txt")); | |
BufferedReader reader2 = new BufferedReader(new FileReader("2.txt")); | |
//BufferedWriter writer = new BufferedWriter(new FileOutputStream("3.txt")); | |
while(true) { | |
int sum = 0; | |
String line1 = reader1.readLine(); | |
String line2 = reader2.readLine(); | |
if (line1 == null && line2 == null) { | |
break; | |
} | |
if (line1 != null) { | |
sum += Integer.valueOf(line1); | |
} | |
if (line2 != null) { | |
sum += Integer.valueOf(line2); | |
} | |
System.out.println(sum); | |
} | |
reader1.close(); | |
reader2.close(); | |
} | |
} |
Author
shalk
commented
Jun 27, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment