Mogu sa tobom da podelim primer iz knjizice Java Examples In A Nutshell koji ide ovako:
import java.io.*;
import java.net.*;
public class GetURL {
public static void main(String[] args) {
InputStream in = null;
OutputStream out = null;
try {
if((args.length != 1) && (args.length != 2))
throw new IllegalArgumentException("Wrong number of args!");
// set up streams
URL url = new URL(args[0]);
in = url.openStream();
if(args.length == 2)
out = new FileOutputStream(args[1]);
else out = System.out;
// now copy bytes
byte[] buffer = new byte[4096];
int bytes_read;
while((bytes_read = in.read(buffer)) != -1)
out.write(buffer,0,bytes_read);
}
catch(Exception e) {
System.err.println(e);
System.err.println("Usage: java GetURL <URL> [<filename>]");
}
finally {
try{
in.close();
out.close();
}
catch(Exception e) {
}
}
}
}
Program koristis tako sto mu kao prvi argument navedes lokaciju slike (adresa koju si naveo), a kao drugi argument mu navedi lokaciju gde zelis da sacuvas i ime fajla...
Npr: java GetURL
http://ia.imdb.com/media/imdb/01/I/20/49/06m.jpg c:\my\slika.jpg
Pozdrav!