Weird download file problem
Hi all,
I'm trying to download a pdf from a website but it doesn't work.
When i try any other website it works, but with this, it doesnt.
I try to download a pdf but instead i get the html content of the home page.
However, if I use a download manager and import the link, the download manager can get the pdf instead of the homepage.
Here's the code:
Code:
URL localURL = new URL("http://krant.tijd.be/pdf/tijd/20100522/1/paper.pdf");
InputStream localInputStream = localURL.openStream();
InputStreamReader localInputStreamReader = new InputStreamReader(localInputStream);
FileOutputStream localFileOutputStream = new FileOutputStream("C:/Users/Glenn/4.pdf");
OutputStreamWriter localOutputStreamWriter = new OutputStreamWriter(localFileOutputStream);
int i;
while ((i = localInputStreamReader.read()) >= 0)
{
localOutputStreamWriter.write(i);
}localOutputStreamWriter.flush();
localOutputStreamWriter.close();
localFileOutputStream.close();
localInputStreamReader.close();
localInputStream.close();
Any help is appreciated because I've searched alot but didn't find anything