LISTSERV mailing list manager LISTSERV 15.5

Help for XML-L Archives


XML-L Archives

XML-L Archives


View:

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

Options:

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
Content-Type:text/plain
Parts/Attachments:
Parts/Attachments

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
Santosh

// Example java copyURL http://www.java.sun.com/Download3/javamain1_1_3.zip
javamail113.zip
//copies javamail1_1_3.zip from java download page onto the current directory on
//your local drive

import java.net.*;
import java.io.*;
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[])
  {(String
     if (args.length < 1)
      {
          System.err.println
               ("usage: java copyURL URL [LocalFile]");
          System.exit(1);      }
      try
      {   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() +
")...");
          System.out.flush();
          FileOutputStream fos=null;
          if (args.length < 2)
          {
              String localFile=null;
              // Get only file name
              StringTokenizer st=new StringTokenizer(url.getFile(), "/");
              while (st.hasMoreTokens())
                     localFile=st.nextToken();
              fos = new FileOutputStream(localFile);          }
          else
              fos = new FileOutputStream(args[1]);
          int oneChar, count=0;
          while ((oneChar=is.read()) != -1)
          {           fos.write(oneChar);
             count++;          }
          is.close();
          fos.close();
          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
"xml".

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?

Thanks,
Janak

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

Permalink



LISTSERV.HEANET.IE

CataList Email List Search Powered by the LISTSERV Email List Manager