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 humanSize(Long ds) {
        String textuse = "";

        if (ds < 1024) {
            textuse = (Long.toString(ds) + "B");
        } else if (ds < (1024 * 1024)) {
            textuse = (Long.toString(ds / 1024) + "K");
        } else if (ds < (1024 * 1024 * 1024)) {
            textuse = (Long.toString(ds / (1024 * 1024)) + "MB");
        } else {
            textuse = (Long.toString(ds / (1024 * 1024 * 1024)) + "GB");
        }

        return textuse;
    }
}