Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Read a file from net!  RSS feed

 
Vrabie Cristian
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just whant to read a file from net. It should be simple but it's not working. Here is my code:

Every time I get an exeception.
It's because the string ("http://www.somePage.com\\index.html"), because servers security or the code is just wrong? If you can please tell me some other ways of dooing this "Reading". If it's important, I whant do use it at an "update module" of one of my softs i'm working at. All this module has to do is to replace some existing files whit some new ones from the net.
Thank you in advance!
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think the below code will work fine. Its working fine at my end.
try {
URL url = new URL("http://www.somesite.com/eng/index.htm");
DataInputStream in = new DataInputStream(url.openStream());
//reading from in.....}catch(Exception e){ System.out.println("ERROR!");}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!