是否有Java等效的GetCompressedFileSize? [英] Is there a Java equivalent of GetCompressedFileSize?

查看:110
本文介绍了是否有Java等效的GetCompressedFileSize?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望得到准确的(即磁盘上的实际大小而不是包含所有0的正常大小)Java中稀疏文件的测量值。

I am looking to get accurate (i.e. the real size on disk and not the normal size that includes all the 0's) measurements of sparse files in Java.

In Windows上的C ++将使用 GetCompressedFileSize 。我还没有想到如何在Java中实现这一目标?

In C++ on Windows one would use GetCompressedFileSize. I have yet to come across how one would go about doing that in Java?

如果没有直接的等价物,我将如何测量数据?稀疏文件,而不是包含所有零的大小?

If there isn't a direct equivalent, how would I go about measuring the data within a sparse file, as opposed to the size including all of the zeros?

为了澄清,我希望在Linux操作系统上同时运行备用文件测量作为Windows,但我不介意编写两个单独的应用程序!

For clarification, I am look for this to run the spare file measurements on both on Linux OS as well as Windows, however I don't mind coding two separate applications!

推荐答案

如果你只在Windows上做,你可以用Java Native Interface编写它

If you are doing it on Windows alone, you can write it with Java Native Interface

class NativeInterface{
   public static native long GetCompressedFileSize(String filename);
}

和C / C ++文件:

and in C/C++ file:

extern "C"
JNIEXPORT jlong JNICALL Java_NativeInterface_GetCompressedFileSize
  (JNIEnv *env, jobject obj, jstring javaString)
{
    const char *nativeString = env->GetStringUTFChars(javaString, 0);

    char buffer[512];
    strcpy(buffer, nativeString);
    env->ReleaseStringUTFChars(javaString, nativeString);
    return (jlong) GetCompressedFileSize(buffer, NULL);
}

这篇关于是否有Java等效的GetCompressedFileSize?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆