java - How do change file names during the execution of the program -
i have run simulations, output should in files, number of outputs can changed simulation other, example, first simulation use 10 files, second 14 files. let's have n files
i declare n
files using following instruction:
string path1="c:/users/desktop/path1.txt"; file file1 =new file(path1);
to write file 1 use function:
write(my outputs list,path1,file1);
during execution, according parameters, select file write on it, option without use of switch case
instruction because not easy manage if number of files big.
with switch case like:
int choice1 = number; switch (choice1) { case 1 : write(outputs ,path1,file1); break; case 2 : write(outputs ,path2,file2); break; case 3 : ....... }
i replace switch case other instruction,
for example, change path, used:
string path= "path"+number;
where number number of path file write on it. can call function write(outputs, path, file)
, same thing file, not know how. please, help.
you can use 'file.renameto(someotherfile)`. might important though: reliable file.renameto() alternative on windows?
Comments
Post a Comment