import java.net.*; import java.io.*; import java.util.*; import javax.imageio.*; import javax.imageio.stream.*; import java.awt.image.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class KW2006 { static boolean KW( String link, String ziel ) { try { System.out.println("Trying URL " + link + "..."); URL url = new URL( link ); URLConnection conn = url.openConnection(); if(! conn.getContentType().toString().equals( "image/jpeg" ) ) { System.out.println( "Not a jpeg: " + conn.getContentType()); return false; } // BufferedReader in = new BufferedReader( new InputStreamReader( conn.getInputStream() ) ); // String line; // while( ( line = in.readLine() ) != null ) { // System.out.println( line ); // } BufferedImage image = ImageIO.read( url ); return ImageIO.write( image, "jpeg", new File( ziel ) ); } catch( Exception ex ) { ex.printStackTrace(); return false; } } public static void main( String args[]) { System.out.println( "Erfolg: " + KW( args[0], args[1] ) ); } }