Hy, I am currently learning Java, and I ve read a lot about file handling in Java but I did not understand yet.
import java.math.BigInteger;
import java.util.Scanner;
public class multiply {
public static void main(String []args) {
Scanner cin = new Scanner(System.in); // Create a Scanner object
String firstNumber = "";
int n = cin.nextInt();
while (n != 0) {
int number = cin.nextInt();
firstNumber = firstNumber + number;
n--;
}
BigInteger number1 = new BigInteger(firstNumber);
String firstNumber2 = "";
int n2 = cin.nextInt();
while (n2 != 0) {
int number2 = cin.nextInt();
firstNumber2 = firstNumber2 + number2;
n2--;
}
BigInteger number2 = new BigInteger(firstNumber2);
//BigInteger res = new BigInteger(number1.multiply(number2));
System.out.println(number1.multiply(number2));
}
}
I ve came up with this program that multiplies big integer but, I dont know what should I add such that it reads from a file named "multiply.in" and it shows the result in a file "multiply.out".
In c++, I know that using ifstream, ofstream solves the problem.
If you could help me with the code it would be very appreciated.