import java.io.*;
import java.net.*;
class Get
{
public static void main( String[] args )
{
if (args.length == 0) {
System.out.println ("Usage : Java Get <dokument>");
System.out.println ("Example: Java Get http://www.server.com/doc.pdf");
System.exit(1);
}
try
{
URL url = new URL(args[0]);
InputStreamReader in = new InputStreamReader (url.openStream());
String name = args[0].substring (args[0].lastIndexOf ("/")+1);
FileOutputStream fos = new FileOutputStream (name);
char[] buf = new char[1024];
byte[] buf2 = new byte[1024];
int nread = 0;
System.out.println ("Lade Datei: "+name);
while ( ( nread = in.read (buf) ) > 0 ) {
for (int i=0; i<nread; i++)
buf2[i] = (byte)buf[i];
fos.write (buf2, 0 ,nread);
}
in.close();
fos.close ();
System.out.println ("Ready.");
}
catch ( Exception e ) {
System.out.println("Error");
}
}
}
Thanks for all your help, I use the code above now!
Greetings, AdamP