Android Question java.lang.NumberFormatException

Discussion in 'Android Questions' started by Rabbit, Feb 19, 2015.

  1. Rabbit

    Rabbit Member Licensed User

    Hi,

    When I try to get the file.size for files about 100MB iI get this message:

    java.lang.NumberFormatException

    Code:
    Dim k As Long  = File.Size(fd.FilePath , fd.ChosenName)/1000000
    how I can get file size without this problem

    by the way,
    when I write

    Log ( File.Size(fd.FilePath , fd.ChosenName)/1000000 )

    I get the result such as 96


    Regards
     
  2. udg

    udg Expert Licensed User

    Hi Rabbit,

    I see you use a long var type (which is an integer number) as result of a division that results in a real number, counting on internal casting, I suppose.
    Read here for a similar thread.
    Just floor the division to obtain the integer part of it or change the var type of k to a real type.

    Edit: AFAIK, that java error means that while converting a "string" to a number, the content of the string doesn't match with the expected number format (e.g. "12.5" can't match an integer).

    udg
     
    Last edited: Feb 19, 2015
  3. Rabbit

    Rabbit Member Licensed User

    Thank you!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice