• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Read a file from net!

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!");}
 
reply
    Bookmark Topic Watch Topic
  • New Topic