Pregunta

I have a for loop that in each iteration a text file should be generated. The problem is naming text file. Because of lack of my knowledge in java, I don't know how I should name output files dynamically. The names should be dependent to the index of for loop. Thanks in advance. I am using printstream.

¿Fue útil?

Solución

Just build a File Name from your index variable.

for(int x = 0; x < 10; x++){
    String fileName = "file_" + x + ".txt";
    File file = new File(fileName);
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top