Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.NumberFormat;

public class Main {
    /**
     * Converts a length of bytes to MB.
     * 
     * @param bytes
     *            The bytes to convert
     * @return A string representation of the MB
     */
    public static String convertBytesToMB(long bytes) {
        double result = (double) bytes / 1000 / 1000;
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(2);
        nf.setGroupingUsed(false);
        return nf.format(result) + " MB";
    }
}