.idea/vcs.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/safeluck/drive/evaluation/app.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
.idea/vcs.xml
New file @@ -0,0 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="VcsDirectoryMappings"> <mapping directory="" vcs="Git" /> </component> </project> app/src/main/java/safeluck/drive/evaluation/app.java
@@ -1,6 +1,7 @@ package safeluck.drive.evaluation; import android.app.Application; import android.os.Environment; import android.text.TextUtils; import android.widget.Toast; @@ -80,6 +81,7 @@ //数据库操作 MyLog.i(TAG, "onCreate111"); FileUtil.createdirs(getApplicationContext()); failedProjRepository = new FailedProjRepository(this); rtkWorkRepository = new RTKWorkRepository(this); } @@ -144,12 +146,23 @@ break; case Constant.FETCH_MAP_INFO: StringBuffer buffer =FileUtil.readAssetTxtFile(this,Constant.MAP); StringBuffer buffer =FileUtil.readTxtFileFromSD(this,Constant.MAP); if (buffer != null){ AYSdk.getInstance().sendCmd(Constant.PUSH_MAP_INFO,buffer.toString()); }else{ MyLog.d(TAG,String.format("地图模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName())); } break; case Constant.REQ_VECHILE_PROFILE: StringBuffer vebuffer =FileUtil.readAssetTxtFile(this,Constant.VEHICLE); StringBuffer vebuffer =FileUtil.readTxtFileFromSD(this,Constant.VEHICLE); if (vebuffer != null){ AYSdk.getInstance().sendCmd(Constant.PUSH_VECHILE_PROFILE,vebuffer.toString()); }else{ MyLog.d(TAG,String.format("车辆模型模型未拷入[%s]目录下", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName())); } break; case Constant.GPS_INFO: Data gpsData = new Data.Builder().putString(Constant.GPS_INFO_DATA,json).build(); app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java
@@ -3,6 +3,10 @@ import android.app.Application; import android.content.Context; import android.content.res.Resources; import android.os.Environment; import android.util.Log; import com.anyun.exam.lib.MyLog; import java.io.BufferedReader; import java.io.File; @@ -14,6 +18,7 @@ import java.io.OutputStream; public class FileUtil { private static final String TAG = "FileUtil"; /** * 读取assert目录下 txt文本文件内容 * @param context @@ -47,6 +52,50 @@ return stringBuffer; } public static void createdirs(Context context){ String dir = Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+context.getPackageName(); File file = new File(dir); if (!file.exists()){ file.mkdir(); }else{ Log.i(TAG, "createdirs: 目录已经存在"); } } public static StringBuffer readTxtFileFromSD(Context context,String fileName){ String lineTxt = null; StringBuffer stringBuffer = new StringBuffer(); try { InputStream inputStream = null; String dir = Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+context.getPackageName(); File file = new File(dir,fileName); if (!file.exists()){ MyLog.d(TAG,fileName+"文件不存在"); return null; } try { inputStream = new FileInputStream(file); } catch (IOException e) { e.printStackTrace(); } InputStreamReader inputStreamReader = new InputStreamReader(inputStream); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); while((lineTxt = bufferedReader.readLine()) != null){ System.out.println(lineTxt); stringBuffer.append(lineTxt); } inputStreamReader.close(); bufferedReader.close(); } catch (IOException e) { e.printStackTrace(); } return stringBuffer; } /** * * @param fromFile 源文件路径包括文件名(绝对路径)