Javaのファイルサイズの決意

パブリック 静的文字列getNetFileSizeDescription(長いサイズ){
        StringBufferのバイト = 新しいStringBufferの();
        DecimalFormat形式 = 新しいてDecimalFormat(" ##### 0。" );
        もし(サイズ> = 1024 * 1024 * 1024 ){
              iは=(サイズ/(1024.0 * 1024.0 * 1024.0 ))。
            bytes.append(format.format(i))をアペンド(。" GB " )。
        }
        そう であれば(サイズ> = 1024 * 1024 ){
             ダブル I =(サイズ/(1024.0 * 1024.0 ))。
            。bytes.append(format.format(i))を追記(" MB " );
        }
        そう であれば(サイズ> = 1024 ){
             ダブル I =(サイズ/(1024.0 ))。
            bytes.append(format.format(i))をアペンド(。" KB " )。
        }
        そう であれば(サイズ< 1024 ){
             場合(サイズ<= 0 ){
                bytes.append(" 0B " )。
            }
            他の{
                bytes.append((INT)サイズ).append(" B " )。
            }
        }

        戻るbytes.toString();
    }

私の元の非

おすすめ

転載: www.cnblogs.com/wcnwcn/p/11805125.html
おすすめ