Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String GetFileSizeStr(long size) {
        if (size > 1000 * 1000 * 1000) {
            return String.format("%.2f GB", size / (double) (1000 * 1000 * 1000));
        } else if (size > 1000 * 1000) {
            return String.format("%.2f MB", size / (double) (1000 * 1000));
        } else if (size > 1000) {
            return String.format("%.2f KB", size / (double) (1000));
        } else {
            return String.format("%d B", size);
        }
    }
}