Java tutorial
//package com.java2s; import java.math.BigDecimal; public class Main { /** * bytes to kb * @param bytes * @return */ public static String bytes2kb(long bytes) { BigDecimal filesize = new BigDecimal(bytes); BigDecimal kilobyte = new BigDecimal(1024); float returnValue = filesize.divide(kilobyte, 2, BigDecimal.ROUND_UP).floatValue(); return (returnValue + " KB "); } }