That would depend on how you wrote it to the file. You could write it in Properties format or as XML or using Java serialization, or an infinite number of other ways. All of these are going to produce files of different sizes.
Do you have a use case where you need to know this number in advance of actually creating the file?
Joined: Jun 16, 2009
I think that one of the map in my application stores a lot of data and it 'eats' my memory. I wonder if there's a way to tell the size (kilo bytes) of the map so I can asses which one is growing in memory.
Then I'm sure it's not the map itself that "eats" the memory, but the objects stored in it. I'd approximately count like this (in bytes):
4 * map.size() + 2 * sum of all key (String) lengths + sum of all values. Of course the most problematic question now is "What is the size of your value object?". If it keeps references to many other objects, then the memory consumption can be high.