UnitOfMemory – Measure and convert you bytes

Not very often do I need to take a number of bytes and convert them into the most appropriate measurement.  This came up recently on a project and I thought it would be nice to just create a class to handle this for me.  So I created UnitOfMemory as enum that switches between Byte, KiloByte, MegaByte, GigaByte, TeraByte, and PetraByte.  This works very nicely to be able to select the appropriate unit to measure with the number of bytes I have, and then to convert.

This is just a simple Java Enum that uses a enum constructor to create an enum type based on the unit of measure of memory.



  • Ghostprogrammer
  • I am known for being able to quickly decipher difficult problems to assist development teams in producing a solution. I have been called upon to be the Team Lead for multiple large-scale projects. I have a keen interest in learning new technologies, always ready for a new challenge.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: