Reading from one file, I need to create logs with the names that are in the file. To do that I put the names from the first file into an array and used PrintWriter to create files to write in. So the names are in an array called names. My code is
i=0;
PrintWriter [] log_name= new PrintWriter[numberofnames];
while (i != numberofnames){
log_names[i]=new PrintWriter("log_"+names[i]+".txt");
i += 1;
}
The problem is, I need refer to specific logs with specific names. So if I know that I have to refer to a log with the a specific name, how would I refer to that log to write into it?
I was thinking that I could do something like this:
String newname="John";
log_newname.println("the message");
but I don't think log_newname would be the same log as the one I named earlier.