I'm trying to code something to copy the content of one file into another existent file without deleting its content. The problem is that, that other existent file is created inside a loop and I don't know how to do it to save it and then using it in another method.
Here's the loop:
if (line.startsWith("tipo1.")) {
FileWriter fw = new FileWriter(name + ".txt");
char[] vector = name.toCharArray();
char[] vector2 = address.toCharArray();
int index = 0;
while (index < vector.length) {
fw.write(vector[index]);
index++;
}
index = 0;
while (index < vector2.length) {
fw.write(vector2[index]);
index++;
}
fw.close();
}
And what I want to do is to save (name + ".txt")
file and then adding the content of another file into it.
I'm sure it's not so difficult to do, but I'm really stuck.