I want to download an ics file with a hyperlink (it's updated permanently, so I always need the latest version) via eclipse, after it is available I want to read out the file, so I can work with it.
And if the file needs to be downloaded to the file system, I want to delete it in the end again.
Unfortunatly I did not find any help in the internet yet and I do not know how to do it.
Sample ICS url: americanhistorycalendar.com/peoplecalendar/1,328-abraham-lincoln?format=ical
I hope someone can help. Just tell me, if you need more information.
Solved my own problem:
public String readICS() throws IOException {
String fileUrl = "http://..."; //ICS-Url
BufferedInputStream in = null;
String ics = null;
try {
in = new BufferedInputStream(new URL(fileUrl).openStream());
byte data[] = new byte[1024];
while (in.read(data, 0, 1024) != -1) {
ics = ics + new String(data);
}
} finally {
if (in != null)
in.close();
}
return ics;
}