On 29 Jun 01, at 11:40, Brian wrote: > I need to find a way to download images off of an http server. Is there > any way of doing this? I'm sure there's an obvious solution right under > my nose but I can't seem to find it. What I want to do is write a script That's funny, I was trying to figure out how to do this just the other day. > datetime_certainimage.jpg. Then I can pipe it through a java applet > and animate it. I have the java stuff worked out but I need to script the > saving of the image. Is there a utility out there that accomplishes I was trying to do this in Java. Since you mention Java, I will assume you will know what to do with this code. Here is a small part of the code I wrote to download a file. I am a novice Java programmer, so I don't claim that this is very efficient - only that it worked for what I was trying to do with some small files! My knowlege of I/O streams is very basic. I wanted to use buffered input and output, but I didn't have time to figure it out. This is just something quick and dirty you can use until you find something that works better. The program takes two command line arguments 1. the URL of the file you want to get. 2. the filename to write the file to. for example... $java DownloadFile "http://www.mn-linux.org/images/tclugminn.jpg" "logo.jpg" Here is the source... ================================================== DownloadFile.java ================================================== import java.io.*; import java.net.*; public class DownloadFile { public static void main( String[] args ) { boolean ok = false; ok = getFile( args[0], args[1] ); if( ok ) { System.out.println("File " + args[1] + " successfully downloaded." ); } else { System.out.println("download failed"); } } static boolean getFile( String page, String filename ) { // declare method variables BufferedInputStream bis = null; InputStream in = null; FileOutputStream fos = null; File file = null; URL url = null; // Try to create the URL object try { url = new URL( page ); } catch( MalformedURLException e ) { System.out.println( "error: could not find URL object" ); } // Try to create the output file object and download it try { in = url.openStream(); file = new File( filename ); System.out.println( "File : " + url.getFile() ); fos = new FileOutputStream( file ); System.out.println(" writing file " + url.getFile() ); // Get the input and write it to the output for(int ch ; -1 != (ch=in.read()) ; ) { fos.write( ch ); } fos.close(); in.close(); } catch( IOException ioe ) { ioe.printStackTrace(); return false; } return true; } } ================================================== Let me know if you find any ways to improve it! Mike Glaser