File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes reading a file from URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "reading a file from URL" Watch "reading a file from URL" New topic

reading a file from URL

vin Hari
Ranch Hand

Joined: Nov 16, 2006
Posts: 161
Hello all,
i am going through one application, the main task is to read a file from url
for example

iam using unix environment iam setting this path to one environment variable. through which iam reading port as :80, protocol as:http
and iam opening url connection through some function and through which iam reading filedescriptor iam getting some number(non zero) which iam giving for ifstream and reading through rdbuf(),but this is not executing,
so please can you tell what are the necessary steps that are required in order to read a file from url. aim using socket programming for this.
Joe Ess

Joined: Oct 29, 2001
Posts: 9191

It would be a good idea to Tell the Details. It does not sound like you are using Java for this task. What language are you using? Can you share some code?

[How To Ask Questions On JavaRanch]
vin Hari
Ranch Hand

Joined: Nov 16, 2006
Posts: 161
Hello thank you,
for reply yes it i correct that iam using unix with c++,but i thought of asking the suggestions as you people give good suggestion,
my question is iam using http protocol to connect, though which iam sending server name

so my question is when i type this URL with file that particular file should get opened ,sorry that i cant send the code because it is very huge,
so please tell how it can be done iam usng socket programming for this.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Have you looked into curl with its c++ bindings? It seems like it would be a lot easier to use an established library like that than to do the socket programming yourself.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Does the url work, if you put it into a browser?

I don't know how to open remote files with c++, but if this isn't a webserver, but a fileserver, you're using the wrong way.
subject: reading a file from URL
It's not a secret anymore!