本地/远程查找文件大小
我正在编写一个程序来查找文件的文件大小。
在java中可以吗?
在 PHP 中我知道有一个 filesize()。
另一种选择是在 unix 中使用 ab http:// 但它如何与 java 集成?
您认为解决此问题的最佳/最有效方法是什么?
I'm writing a program to find the file size of files.
Is it possible in java?
In PHP I know there is a filesize().
Another alternative was using ab http:// in unix but how is it integratabtle with java?
What do you think is the best/most efficient way to attack this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 java Runtime 来执行命令并从缓冲区读取输出并显示它。
如果您本地有该文件,则可以使用 File.length()
You can use java Runtime to execute the command and read the output from the buffer and display it.
If you have the file locally, then you can use File.length()
检索页面,提取链接,然后仅请求每个 uri 的标头。
PHP 中的 filesize() 可能比较冒险,因为是否允许您在远程文件上使用它完全取决于主机的配置。您可能会考虑使用curl代替
使用shell中的curl,例如,在我写下以下内容时查看页面右侧的广告:
...产量,除其他外:
...这可能就是您正在寻找的内容为了。在 PHP 中,使用 CURLOPT_NOBODY 获得等效内容
Retrieve a page, extract links, and then only request the header for each uri.
filesize() in PHP may be dicey, as whether or not you're allowed to use it on a remote file will be entirely up to the configuration of your host. You might consider curl instead
Using curl from a shell, for instance, to look at an ad on the rhs of the page as I write this:
...yields, among other things:
...which may be what you're looking for. Within PHP, get the equivalent with CURLOPT_NOBODY