File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes how to read files from internet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "how to read files from internet" Watch "how to read files from internet" New topic
Author

how to read files from internet

Cody Long
Ranch Hand

Joined: Jan 01, 2009
Posts: 95
if i post a txt file on the internet is it possible to make a program to read this file?


Duct tape is like the Force. It has a dark side, a light side, and it binds the whole universe together.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39544
    
  27
Yes: http://www.exampledepot.com/egs/java.net/ReadFromURL.html


Ping & DNS - updated with new look and Ping home screen widget
zahid zubair
Ranch Hand

Joined: Aug 29, 2009
Posts: 32
Hi Guys,

I just tried your suggestion, I am getting the following exception after a couple of seconds:



I too want to know about this. Can anyone please help me out to resolve this exception? I am using a proxy server which requires authentication to access the internet. Is it anything to do with this?

Thanks for your help...!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18115
    
    8

zahid zubair wrote:I am using a proxy server which requires authentication to access the internet. Is it anything to do with this?


Quite likely yes. Here's a link to Sun's writeup about how to connect via proxy servers. It's possible that just implementing that will automatically deal with the authentication, but it depends on what platform your code is running on and what kind of proxy server it is and so on.
zahid zubair
Ranch Hand

Joined: Aug 29, 2009
Posts: 32
Hi,

Thanks for your response. I gone through it and was able to accomplish my task using the website given and some google search on java website.



However, I don't understand why the proxyType is set to 4, what does it mean?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8707
    
    6

zahid zubair wrote:
However, I don't understand why the proxyType is set to 4, what does it mean?


I don't see anything about that system property in the JDK Networking Documentation. Where did you find it?
The java.net.Proxy class is probably easier to deal with than the system properties. Have a look here for an example.
zahid zubair
Ranch Hand

Joined: Aug 29, 2009
Posts: 32
While I was receiving the HTTP 407 error when I tried the code in the url posted by you, I found the resolution in http://forums.sun.com/thread.jspa?threadID=500360
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8707
    
    6

zahid zubair wrote:While I was receiving the HTTP 407 error when I tried the code in the url posted by you


I'm not Ulf or Paul
I can't find any references to the "http.proxyType" property. The links in that thread don't mention it. The original poster says he got it from another thread, but searching that forum only brings up his post. I think he imagined it.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18115
    
    8

Likewise there isn't anything about

in that documentation either.

You'll find that it makes no difference whether you use this system property or not, because it isn't used by any of the JRE code. It's a bogus property, in other words, which somebody thought up years ago and it's been copied from one internet site to another without anybody checking it.
zahid zubair
Ranch Hand

Joined: Aug 29, 2009
Posts: 32
Oh. Is it so!!! Thanks for making me aware guys. However, my code copying mistake might have made others aware as well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to read files from internet
 
Similar Threads
applet and JDBC
what is the first thing you do after coming to office?
File Reader(Urgent)
getImage Problem
reading file