I am having a hard time getting my program to add all the XML data from the URL to a .txt file without always writing over the data that is already in the aforementioned file. I am trying to use the program to get XML data for all videos uploaded by a channel into a .txt file which will be referenced later.
filename = new File("xmlData.txt");
filename.createNewFile();
while (flag1 == 0)
{
URL url = new URL("https://gdata.youtube.com/feeds/api/users/"+Name+"/uploads? max-query=50&start-index="+index);
try (BufferedReader br = new BufferedReader(
new InputStreamReader(url.openStream())))
{
while ((inputLine = br.readLine()) != null)
{
try (BufferedWriter bw = new BufferedWriter(new FileWriter(filename)))
{
bw.write(inputLine);
bw.newLine();
}
}
}
if (count1 < 25)
{
index = index+50;
count1++;
}
else
{
flag1 = 1;
}
}
System.out.println("Done writing to xmlData.txt");