File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Help - Streaming/File IO

 
Em Aiy
Ranch Hand
Posts: 226
  • 0
  • 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.
 
Rob Spoor
Sheriff
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • 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
  • 0
  • 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
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • 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