• Post Reply Bookmark Topic Watch Topic
  • New Topic

Downloading File From URL  RSS feed

 
Aryeh Golob
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing an application that draws resources from multiple sources. Most of those sources are located on FTP servers that I access using the commons-net apache package.

I currently have a resource, in this case a text file, that I need to access from a URL. If I enter the URL in my browser, I will get a download prompt to begin downloading this file.

The URL looks something like this (changed for security of course).

http://resourceloc.com/ecom/inventory.asp?custid=1234&pwd=1234

I need to have my application download this resource (text file) a few times a day and process it.

I have not done this before, so I was looking for some advice regarding how to proceed.

Any advice/insight is greatly appreciate!!
 
Aryeh Golob
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found this piece of code from here.

Does this look right?

 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Aryeh Golob:


You can just change that condition to the simple "lastSlashIndex != -1" or "lastSlashIndex >= 0". By definition,lastSlashIndex will either be -1 or a valid index, and therefore automatically between 0 (inclusive) and address.length() (exclusive).

The copying part seems just fine.

One more note though: what if your URL ends with a /?
[ November 19, 2008: Message edited by: Rob Prime ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!