Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想要可以获取文件大小并将其更改为 KB 和 MB 的代码
562 KB = 562 KB 1024 KB = 1 MB 2152 KB = 2.15 MB
先感谢您。
这是:
public String size(int size){ String hrSize = ""; double m = size/1024.0; DecimalFormat dec = new DecimalFormat("0.00"); if (m > 1) { hrSize = dec.format(m).concat(" MB"); } else { hrSize = dec.format(size).concat(" KB"); } return hrSize; }
来源:动态将 KB 转换为 MB、GB、TB
我将一组 html 代码传递给 php 函数,目的是提取并返回它的子集。
这是传入数据的部分示例:
[0] => <div class="positionIs" style="float:right;width:181px;"> [1] => <table class="datab