im trying to add counter in loop to a variable so the variable name changes during the loop as i am writing to a file so all the files has to be assigned a different variable name.
String[] pathnames;
String tomcatUserFile="";
String contextFile="";
//Path tomcatConfDir=Paths.get(prop.getProperty("testClasspath"));
File f = new File(prop.getProperty("tomcatZip"));
pathnames=f.list();
int c=0;
for (String i : pathnames) {
c++;
tomcatUserFile = prop.getProperty("tomcatZip")+i+"/conf/tomcat-users.xml";
Path tomcatUser= Paths.get(tomcatUserFile);
contextFile = prop.getProperty("tomcatZip")+i+"/conf/context.xml";
Path tomcatContext= Paths.get(contextFile);
String tomcatUserFileContent+i = new String(Files.readAllBytes(tomcatUser),StandardCharsets.UTF_8);
log.info(prop.getProperty("SUCCESS"));
}
Files.write(tomcatUser,tomcatUserFileContent+i.getBytes());
i added +i to my variable tomcatUserFileContent so it changes the variable name every loop eg :tomcatUserFileContent0,tomcatUserFileContent1 etc but its not working. Any help?