【发布时间】:2019-05-18 17:13:23
【问题描述】:
只要 isSaveCSV() 为真,我就会尝试将我的 Android 7 智能手机中的 GPS 数据导出到 .csv 文件一段时间。
public void saveCSVfile() {
if (isSaveCSV()) {
Long time = System.currentTimeMillis()/1000;
String entry =time.toString()+","+lat+","+lon+"\n";
if (csv_created==false) {
csv_created=true;
FILECOUNT++;
NEWFILENAME = FILENAME+FILECOUNT+".csv";
File myDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "tensorflow");
csvfile = new File(myDir, NEWFILENAME);
try {
FileOutputStream out = new FileOutputStream(csvfile);
out.write( entry.getBytes() );
out.close();
} catch (final Exception e) {
LOGGER.e(e, "Exception!");
}
}else {
try {
entry="TESTFORFOOSAKE";
FileOutputStream out = openFileOutput(csvfile.getName(), Context.MODE_APPEND);
out.write(entry.getBytes());
out.close();
} catch (final Exception e) {
LOGGER.e(e, "Exception!");
}
}
}else {
csv_created=false;
}
}
文件总是一行..我从未见过双行文件..
【问题讨论】:
标签: java android android-7.0-nougat