Interview Questions

Java - Convert Bytes to KB,MB,GB etc...

import org.apache.commons.io.FileUtils;

public static void main(String[] args){
               
                System.out.println(FileUtils.byteCountToDisplaySize(9978500));
        }

Output:

9 MB

5
Average: 5 (1 vote)
Your rating: None