LISTSERV mailing list manager LISTSERV 15.5

Help for XML-L Archives

XML-L Archives

XML-L Archives


Next Message | Previous Message
Next in Topic | Previous in Topic
Next by Same Author | Previous by Same Author
Chronologically | Most Recent First
Proportional Font | Monospaced Font


Join or Leave XML-L
Reply | Post New Message
Search Archives

Subject: Re: Downloading an XML file over HTTP on Windows 2000
From: Santosh Daryani <[log in to unmask]>
Reply-To:General discussion of Extensible Markup Language <[log in to unmask]>
Date:Tue, 17 Oct 2000 17:02:13 -0400

text/plain (124 lines)

I have a java program that copies a file from a url , also I was downloading
this file using an automated process ,
on unix you can have a cron job , or on Novell or NT you can have a scheduled
job that calls this java program.

Here's the code for copying the file from a URL.

Hope that helps

// Example java copyURL
//copies from java download page onto the current directory on
//your local drive

import java.util.Date;
import java.util.StringTokenizer;
import java.util.*;

public class copyURL implements ContentHandlerFactory

  public ContentHandler createContentHandler(String mimetype)
       return this.createContentHandler(mimetype);

  public static void main(String args[])
     if (args.length < 1)
               ("usage: java copyURL URL [LocalFile]");
          System.exit(1);      }
      {   System.out.println("Opening connection:\n" + '[' + args[0] + ']');
          URL url = new URL(args[0]);
          System.out.println("Opening connection to " + args[0] + "...");
          URLConnection urlC = url.openConnection();
          InputStream is = url.openStream();

          // Print info about resource
          System.out.print("Copying resource (type: " + urlC.getContentType());
          Date date=new Date(urlC.getLastModified());
          System.out.println(", modified on: " + date.toLocaleString() +
          FileOutputStream fos=null;
          if (args.length < 2)
              String localFile=null;
              // Get only file name
              StringTokenizer st=new StringTokenizer(url.getFile(), "/");
              while (st.hasMoreTokens())
              fos = new FileOutputStream(localFile);          }
              fos = new FileOutputStream(args[1]);
          int oneChar, count=0;
          while (( != -1)
          {           fos.write(oneChar);
             count++;          }
          System.out.println(count + " byte(s) copied");
      catch (MalformedURLException e)
      { System.err.println(e.toString()); }
      catch (IOException e)
      { System.err.println(e.toString()); }

Janak Parekh <[log in to unmask]> on 10/17/2000 02:09:38 PM

Please respond to General discussion of Extensible Markup Language
      <[log in to unmask]>

To:   [log in to unmask]
cc:    (bcc: Santosh Daryani/IT/Aon Consulting)

Subject:  Downloading an XML file over HTTP on Windows 2000

Hi everyone,

I am trying to download an XML file from a client's servers to our servers
over HTTP. I need to download it from their server every 15 mins. The URL
that the client gave me is an ASP file w/ a querystring "&xml=1". So, I'm
assuming that asp page loads the XML page when it sees the querystring

I've been researching on a way to automate this process on Windows 2000
w/out much success. I've tried looking at the Windows Scripting Host, but it
doesn't have any method/property to access an external URL at a given
schedule and download the file.

If someone has already done something like this w/ success, can you help me
out w/ this?


Back to: Top of Message | Previous Page | Main XML-L Page



CataList Email List Search Powered by the LISTSERV Email List Manager