Win a copy of Head First Android this week in the Android 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

URL Connection Stream

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all!
I have a question regarding URl and URL COnnection. What is the fifference between URLConnection.getInputStream and URL.openStream? They should be the same right? In our application we are opening a URLCOnnection from a URL object to get contenttype, length etc. Then using the same URLObject we are opening stream with openstream and writing out to another stream. Sometimes the length returned by URLConnection is different from the total bytes read from URL.openStream() method. Why is that?

Here are the steps again
1) Create URL Object -- say URLObj1

2) Create URLCOnnection --- URLCon1

3) get contentlength from URLCon1 -- contentLength1

4) OpenStream from URLObj1 as UrlObj1.openStream()

5) Write the above to another stream and count the total bytes read. -- totbytes

6) Sometimes totbytes is different from contentLength1
Why?

Thanks
Sreenath
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic