Here you can find the source of convertBytesToKBytes(String value)
Parameter | Description |
---|---|
value | a parameter |
public static Long convertBytesToKBytes(String value)
//package com.java2s; import java.math.BigDecimal; import java.math.RoundingMode; public class Main { private static final String KILOBYTECONVERTERVALUE = "1024"; /**//w w w.jav a2s. c o m * convert Bytes to KiloBytes * * @param value * @return */ public static Long convertBytesToKBytes(String value) { if (null == value) { return 0L; } BigDecimal val = new BigDecimal(value); BigDecimal kbconverter = new BigDecimal(KILOBYTECONVERTERVALUE); BigDecimal result = val.divide(kbconverter, RoundingMode.CEILING); // if the passed in Value from Provider is less than 1024 bytes, then by // default make it to 1 KB. if (result.longValue() == 0) { return 1L; } return result.longValue(); } }