hello,
Thank you in advance...
I'm trying to write a function that gets a file using java.net.URL
I'm able to download ascii (.html) files with no problems (so far); but when i try to download a .jpg the file gets truncated.
The actual file size is 52,177 bytes; but i only get 2,489 bytes.
Here's the function:
public void getFile(
String pUrl)
{
try
{
URL lUrl = new URL(pUrl);
URLConnection lUrlConnection = lUrl.openConnection();
InputStream lInputStream = lUrl.openStream();
DataInputStream lDataInputStream = new DataInputStream(lInputStream);
FileOutputStream lFileOutputStream = null;
String lPrefix = "./dfiles/";
String lLocalFile = null;
lFileOutputStream = new FileOutputStream(lPrefix + "MyFile.jpg");
for(;
{
byte lData = lDataInputStream.readByte();
try
{
lFileOutputStream.write(lData);
}
catch(EOFException e)
{
break;
}
}
lDataInputStream.close();
lFileOutputStream.close();
}
catch(MalformedURLException e)
{
System.err.println(e.toString());
}
catch(IOException e)
{
System.err.println(e.toString());
}
}
any help or insights would be greatly appreciated.
sincerely,
me.