I have to run some simulations, the output should be in files, the number of outputs can be changed from simulation to the other, for example, the first simulation I use 10 files, the second will be 14 files. let's say I have N files
I declare the N
files using the following instruction:
String path1="C:/Users/Desktop/path1.txt";
File file1 =new File(path1);
to write into the file 1 I use this function:
write(my outputs list,path1,file1);
during the execution, according to some parameters, I select the file to write on it, I would like to do this option without the use of the switch case
instruction because it is not easy to manage it if the number of files is big.
with switch case it would be something like:
int choice1 = number;
switch (choice1) {
case 1 :
write(outputs ,path1,file1);
break;
case 2 :
write(outputs ,path2,file2);
break;
case 3 :
.......
}
I would like to replace the switch case with other instruction,
for example, to change the path, I used:
String path= "path"+number;
where number is the number of the path file to write on it.
then I can call for my function write(outputs, path, file)
, but
I would like to do the same thing for file, but I do not know how.
Please, any help.