Java Number Format Pattern formatiereSpeichergroesse(long bytes)

Here you can find the source of formatiereSpeichergroesse(long bytes)

Description

formatiere Speichergroesse

License

Open Source License

Declaration

static String formatiereSpeichergroesse(long bytes) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.DecimalFormat;

public class Main {
    static final DecimalFormat DF_2 = new DecimalFormat("#,##0.00");

    static String formatiereSpeichergroesse(long bytes) {
        if (bytes < 0)
            return "0 Byte";
        if (bytes < 1024)
            return "" + bytes + " Byte";
        double b = bytes / 1024.;
        if (b < 1024.)
            return DF_2.format(b) + " KByte";
        return DF_2.format(b / 1024.) + " MByte";
    }// ww w .j  a va 2  s  .co m
}

Related

  1. formatDollar(Object obj)
  2. formatDollarTd(Object obj)
  3. formatFileLength(long length)
  4. formatGopNumber(Number gop)
  5. formatI18N(Object ob)
  6. formatIncludeCommas(final Number object)
  7. formatInt(final int number)
  8. formatInteger(Object obj)
  9. formatIntoCurr(String str_number, int digits)