xxx.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_company_base_GPSEncode */
#ifndef _Included_com_company_base_GPSEncode
#define _Included_com_company_base_GPSEncode
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_fleety_base_GPSEncode
* Method: encode
* Signature: (DD[D)Z
*/
JNIEXPORT jboolean JNICALL Java_com_company_base_GPSEncode_encode
(JNIEnv *, jclass, jdouble, jdouble, jdoubleArray);
/*
* Class: com_fleety_base_GPSDecode
* Method: decode
* Signature: (DD[D)Z
*/
JNIEXPORT jboolean JNICALL Java_com_company_base_GPSEncode_decode
(JNIEnv *, jclass, jdouble, jdouble, jdoubleArray);
#ifdef __cplusplus
}
#endif
#endif
xxx.cpp
#include "stdafx.h"
#include <stdio.h>
#include "xxx.h"
#include "DataLib.h"
JNIEXPORT jboolean JNICALL Java_com_company_base_GPSEncode_encode
(JNIEnv* env, jclass cls, jdouble lo, jdouble la, jdoubleArray jResultArr)
{
// printf("test encode!\n");
double loOut = 0;
double laOut = 0;
bool bResult = encode(lo,la,loOut,laOut);
if(bResult)
{
env->SetDoubleArrayRegion(jResultArr,0,1,&loOut);
env->SetDoubleArrayRegion(jResultArr,1,1,&laOut);
}
return bResult;
}
JNIEXPORT jboolean JNICALL Java_com_company_base_GPSEncode_decode
(JNIEnv* env, jclass cls, jdouble lo, jdouble la, jdoubleArray jResultArr)
{
// printf("test decode!\n");
double loOut = 0;
double laOut = 0;
bool bResult = decode(lo,la,loOut,laOut);
if(bResult)
{
env->SetDoubleArrayRegion(jResultArr,0,1,&loOut);
env->SetDoubleArrayRegion(jResultArr,1,1,&laOut);
1. 字符串有整型的相互转换
Java代码
String a = String.valueOf(2); //integer to numeric string
int i = Integer.parseInt(a); //numeric string to an int
2. 向文件末尾添加内容
Java代码
BufferedWriter out = null;
try {
out = new BufferedWriter(new FileWr ......