#include <string.h> #include <jni.h> #include <stdio.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/time.h> #include <android/log.h> #define LOG_TAG "System.out.c" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) long createFile() { struct timeval start; struct timeval end; gettimeofday(&start,NULL); FILE *pfile=fopen("/sdcard/test1g.dat","a+"); int n=truncate("/sdcard/test1g.dat",5024000); gettimeofday(&end,NULL); long time = end.tv_sec-start.tv_sec; LOGD("time=%ld", time); return time; } jstring Java_com_su_testjni_HelloJniActivity_stringFromJNI(JNIEnv* env, jobject thiz) { long time = createFile(); return (*env)->NewStringUTF(env, "Hello from JNI !"); }
NDK快速创建大文件
最新推荐文章于 2021-11-24 08:57:09 发布
553

被折叠的 条评论
为什么被折叠?



