Hi, I'm trying to download a zip-file with an URLConnection. But inputStream.read(buffer)) returns always -1.If I use another address to a normal html-page, it works. See my code below.
Can anyone help?
URL url = new URL(address);
outputStream = new BufferedOutputStream(new FileOutputStream(localFileName));
URLConnection urlConnection = url.openConnection();
inputStream = urlConnection.getInputStream();
byte buffer = new byte;
long numWritten = 0;
while ((numRead = inputStream.read(buffer)) != -1)
outputStream.write(buffer, 0, numRead);
numWritten += numRead;