Android Question java.lang.NumberFormatException

Rabbit

Member
Licensed User
Longtime User
Hi,

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

java.lang.NumberFormatException

B4X:
    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
 

udg

Expert
Licensed User
Longtime 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:
Upvote 0
Top