• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Need Help - Streaming/File IO

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to read from some html pages from website and need to write those html pages in given file in "chunks".

like there is some html page named .. www.somedomain.com/myinfo.html .. the page is really lengthy, so what i need to do is to create a file and write the data in it in chunks. but I am unsure about 2-3 things. Not un-sure, rather i don't know


1: how to read html page from web?
2: I need to write in file - how can i pause the constant reading stream of html page and write the read data in some file ?

Please guide.
 
Sheriff
Posts: 22018
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Muhammad Ali wrote:1: how to read html page from web?


Using URL and URLConnection. The latter has a method called getInputStream() - guess what that returns

2: I need to write in file - how can i pause the constant reading stream of html page and write the read data in some file ?


Simply pause reading from the InputStream.
 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what do you mean "pause". That is the biggest thing confusing me? do i need to write in file through some thread or should i write in same thread? is the pause method is InputStream specific .. or i have to do it ?
 
Rob Spoor
Sheriff
Posts: 22018
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to do it. The InputStream will probably not transfer much data if you're not going to read from it. And if it does, you can't stop it anyway because it's an OS issue, but you still can ignore it for the time being, then read it when you're ready.
 
reply
    Bookmark Topic Watch Topic
  • New Topic