T
Timo Nentwig
Hi!
I download a JPG and write it to disk; this is rather old code which
certainly worked. The only thing I'm aware of that changed is JDK 1.4 ->
1.5b2. The written file is corrupt:
URL u = new URL ("http://foo/bar.jpg");
DataInputStream in = new DataInputStream
(u.openConnection().getInputStream());
File f = new File (foo);
FileOutputStream fs = new FileOutputStream (f);
DataOutputStream out = new DataOutputStream (fs);
for (int b; (b = in.read ()) != -1
{
out.write (b);
}
in.close();
fs.close();
out.close();
What's wrong? And, can I repair the corrupt files?
I download a JPG and write it to disk; this is rather old code which
certainly worked. The only thing I'm aware of that changed is JDK 1.4 ->
1.5b2. The written file is corrupt:
URL u = new URL ("http://foo/bar.jpg");
DataInputStream in = new DataInputStream
(u.openConnection().getInputStream());
File f = new File (foo);
FileOutputStream fs = new FileOutputStream (f);
DataOutputStream out = new DataOutputStream (fs);
for (int b; (b = in.read ()) != -1
{
out.write (b);
}
in.close();
fs.close();
out.close();
What's wrong? And, can I repair the corrupt files?