Why dont you use recursion. put the file writing code into one method.
Giving blueprint below please try to implement that way.
public class CSV {
String data1;
String data2;
boolean runnung=false;
int globalvariable = 1;
public void fileWrite(){
FileInputStream ar= new FileInputStream("filelocation");
FileWriter dr= new Filewriter("datafile"+globalvariable.csv");
dr.close();
//while (running) {
if (data=some number) {
fileWrite();
} else {
result=data1+data2;
}
ar.close();
//}
}
}
Hope this will help you.
7
solved How can I re-run java code from the java program?