I want to read texts from two or more files using using main methods array. Is it possible? (my code could be a little strange because I'm a beginner)
Here is my code.
public static void main(String[] args) throws IOException {
if(args.length != 1)
{
System.out.println("wrong number of arguments");
System.exit(1);
}
args[0] = "data.txt";
args[1] = "data2.txt";
BufferedReader file = new BufferedReader(new FileReader(args[0],args[1]));
int NumberofRows =0, NumberofCharacter =0;
while(true)
{
String row = file.readLine();
if(row == null)
break;
NumberofRows++;
NumberofCharacter = NumberofCharacter + row.length();
}
System.out.println("The files "+" data.txt " + " and " "data2.txt "+ "contains "+ NumberofRows+ "rows and NumberofCharacter contains"+
NumberofCharacter +" character");
file.close();