File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Create a file object from avilable in a URL without downloading it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Create a file object from avilable in a URL without downloading it" Watch "Create a file object from avilable in a URL without downloading it" New topic
Author

Create a file object from avilable in a URL without downloading it

Ganesh Kamath
Greenhorn

Joined: Jan 12, 2009
Posts: 2
Hi ,

I need to create a file object for data available in a given URL.whats the best and the effecient way of doing it?

Regards,
Ganesh
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Ganesh and welcome to Javaranch!

Have you taken a look at the File API in Java? It contains what you need


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Ganesh Kamath
Greenhorn

Joined: Jan 12, 2009
Posts: 2
Hi Verburg,

I am using the following code to achieve the result but it downloads the files to the local machine



Is it possible to prevent the downloading of the file to the local machine?

Regards,
Ganesh
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Ah, now I think understand your problem .

You want to write a file at a remote URL location?

One option: The File constructor will take a file: based URI as an argument, as long as you have permission to write to that location (if it's on a remote machine you'll need to have a file share setup).

Another Option: Use an FTP library to send the file to the remote location after you have written it locally (requires FTP servers to be running, oh and best to use Apache Commons Net library for this).

There are many other ways to solve this as well, but a key thing is that the remote location must give you permission to write files there.

PS: Oh as a quick admin thing, you can wrap your code in code tags (I've done this for you), makes the code more readable.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Create a file object from avilable in a URL without downloading it