C++
void saveFeature(const char * filePath,const char* data,int len)
{
FILE *fp=fopen(filePath,"wb");
if(fp)
{
fwrite(data,512,len,fp);
fclose(fp);
}
}
// FILE *fp = fopen("/sdcard/s320/enroll_byte_jni.bin", "wb");
// if (fp)
// {
// fwrite((char*)byteF, 2048, 1, fp);
// }
// fclose(fp);
Android
public static void saveBin(byte[] bmp, String name) {
File f = new File("/sdcard/" + name + ".bin");
try {
f.createNewFile();
} catch (IOException e) {
}
try {
InputStream is = new ByteArrayInputStream(bmp);
FileOutputStream os = new FileOutputStream(f);
byte[] b = new byte[1024];
int len = 0;
//开始读取
while ((len = is.read(b)) != -1) {
os.write(b, 0, len);
}
//完毕关闭所有连接
is.close();
os.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}