9 Replies - 8297 Views - Last Post: 30 May 2008 - 02:50 AM Rate Topic: -----

#1 HypnotiqBIG  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 28-May 08

Get file size before download

Posted 29 May 2008 - 09:13 PM

Continuation of issues arising from my programa from here.

I wish to find a way to gain the size of a file before the download of the file itself (off the internet) actually commenses, for the purpose of using it for the progress bar for the download.

We have tried the InputStream.available() method, and it returns false values.

Any assistance much appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Get file size before download

#2 HypnotiqBIG  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 28-May 08

Re: Get file size before download

Posted 29 May 2008 - 09:31 PM

i found this; conn.getContentLength()
it returns the correct value.
how do i incorporate this intothe progress bar? and what do i modify the counter by? (multiply/divide it by something?)

[Directed at u pbl, uv helped me consistantly ty :)]

This post has been edited by HypnotiqBIG: 29 May 2008 - 09:32 PM

Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Get file size before download

Posted 29 May 2008 - 09:35 PM

View PostHypnotiqBIG, on 29 May, 2008 - 09:31 PM, said:

i found this; conn.getContentLength()
it returns the correct value.
how do i incorporate this intothe progress bar? and what do i modify the counter by? (multiply/divide it by something?)

[Directed at u pbl, uv helped me consistantly ty :)]

What kind of object is conn ?
Was This Post Helpful? 0
  • +
  • -

#4 HypnotiqBIG  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 28-May 08

Re: Get file size before download

Posted 29 May 2008 - 09:38 PM

View Postpbl, on 30 May, 2008 - 12:35 AM, said:

What kind of object is conn ?

conn = url.openConnection();

and it returns an int
Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Get file size before download

Posted 29 May 2008 - 09:51 PM

View PostHypnotiqBIG, on 29 May, 2008 - 09:38 PM, said:

View Postpbl, on 30 May, 2008 - 12:35 AM, said:

What kind of object is conn ?

conn = url.openConnection();

and it returns an int

No will only returns to you the lenght of the Header of that html file

Try Google with different patterns you might found the solution there

This post has been edited by pbl: 29 May 2008 - 09:55 PM

Was This Post Helpful? 0
  • +
  • -

#6 HypnotiqBIG  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 28-May 08

Re: Get file size before download

Posted 29 May 2008 - 09:59 PM

View Postpbl, on 30 May, 2008 - 12:51 AM, said:

No will only returns to you the lenght of the Header of that html file

Try Google with different patterns you might found the solution there

Yea, even if it does only return the length of the header, that will suffice for now, how do i incorporate this newly gained data into the counter and progress bar?

This post has been edited by HypnotiqBIG: 29 May 2008 - 09:59 PM

Was This Post Helpful? 0
  • +
  • -

#7 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Get file size before download

Posted 29 May 2008 - 10:17 PM

Enough is enough

HypnotiqBIG we have tried to help you as much as we could in a voluntary context

We proposed you solutions
Now it is the time for you to do your homeworks

You downloaded the code that will download whatever you want from thr WEB

so if

Quote

EnYea, even if it does only return the length of the header, that will suffice for now, how do i incorporate this newly gained data into the counter and progress bar?

good for you
Was This Post Helpful? 0
  • +
  • -

#8 HypnotiqBIG  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 28-May 08

Re: Get file size before download

Posted 29 May 2008 - 10:30 PM

jeez calm down, if u didn't have any help to post why waste ur time?
Was This Post Helpful? 0
  • +
  • -

#9 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: Get file size before download

Posted 30 May 2008 - 02:50 AM

He just tried to guide you into the direction how things work here. We usually don't post full solutions, just show you the way. Or if you have a code that has some problems, we help to fix them.
Actually we have nice standard answer for such situations:
Was This Post Helpful? 0
  • +
  • -

#10 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: Get file size before download

Posted 30 May 2008 - 02:50 AM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1