Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Need Help - Streaming/File IO  RSS feed

 
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: 21452
95
Chrome Eclipse IDE Java 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: 21452
95
Chrome Eclipse IDE Java 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!