Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ganesh Kamath
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ganesh and welcome to Javaranch!

Have you taken a look at the File API in Java? It contains what you need
 
Ganesh Kamath
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic