I need to know how to download images from a web site to my computer using i/o (or a better way if one is known). Using the available input and output streams my pictures end up, well, not like they used to be. Any help is much appreciated.
Post some of your I/O code here so we can see what you're trying to attempt. I'm assuming this is a JAVA application rather than an applet, since an applet severly restricts I/O due to security. Unless it's a trusted applet. -Peter
This is my code. The URL is created here because 'url' is a string previous to this code. I know this does not work on images becuase of the way they are made, but I can't think of how else to do it. Thanks
Noah, The problem with your code is you're using a Reader/Writer stream which is meant to read character (i.e. text) streams rather than a binary stream. Change your code to use BufferedInput/BufferedOutput stream. -Peter
You need to use InputStream/OutputStream or BufferInputStream/BufferOutputStream to read or write image files try floowing code: readImage(InputStream from, OutputStream to) { BufferedInputStream from = new BufferedInputStream(from); BufferInputStream to = new BufferedOutputStream(to); int c; byte buf[] = new byte[2048]; try { System.out.println("read the other files!\n"); while((c=from.read(buf)) > -1) { to.write(buf); to.flush(); } } catch (EOFException e) {} catch (Exception e){} }