From 6a5fa29439444a5d5bd739554a1aea22473d31b6 Mon Sep 17 00:00:00 2001
From: lizhanwei <Dana_Lee1016@126.com>
Date: 星期三, 12 二月 2020 19:45:25 +0800
Subject: [PATCH] 测试地图点
---
app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java | 71 ++++++++++++++++++++++++++++++++++-
1 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java b/app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java
index d63b1b0..57cb041 100644
--- a/app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java
+++ b/app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java
@@ -19,6 +19,10 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.util.List;
+import java.util.Map;
+
+import safeluck.drive.evaluation.bean.ExamMap;
public class FileUtil {
private static final String TAG = "FileUtil";
@@ -165,6 +169,7 @@
* @param assertfileName
*/
public static void copyAssertFileToSD(Context context,String assertfileName){
+
try {
InputStream inputStream = null;
try {
@@ -173,14 +178,16 @@
} catch (IOException e) {
e.printStackTrace();
}
+ deleteFile(context.getPackageName()+"/",assertfileName);
+
OutputStream outputStream = new FileOutputStream( new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+context.getPackageName(), assertfileName));
byte[] bytes = new byte[1024];
while ((inputStream.read(bytes))>0){
outputStream.write(bytes);
}
- inputStream.close();
outputStream.close();
- } catch (IOException e) {
+ inputStream.close();
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -226,4 +233,64 @@
return out.toByteArray();
}
+
+ private static final String SEP2 = "|";
+
+ private static final String SEP3 = "=";
+
+ private static final String SEP1 = "#";
+
+ public static String ListToString(List<?> list) {
+ StringBuffer sb = new StringBuffer();
+ if (list != null && list.size() > 0) {
+ for (int i = 0; i < list.size(); i++) {
+ if (list.get(i) == null || list.get(i) == "") {
+ continue;
+ }
+ // 濡傛灉鍊兼槸list绫诲瀷鍒欒皟鐢ㄨ嚜宸�
+ if (list.get(i) instanceof List) {
+ sb.append(ListToString((List<?>) list.get(i)));
+ sb.append(SEP1);
+ } else if (list.get(i) instanceof Map) {
+ sb.append(MapToString((Map<?, ?>) list.get(i)));
+ sb.append(SEP1);
+ } else {
+ sb.append(list.get(i));
+ sb.append(SEP1);
+ }
+ }
+ }
+ return "L" + sb.toString();
+ }
+ /**
+ * Map杞崲String
+ *
+ * @param map
+ * :闇�瑕佽浆鎹㈢殑Map
+ * @return String杞崲鍚庣殑瀛楃涓�
+ */
+ public static String MapToString(Map<?, ?> map) {
+ StringBuffer sb = new StringBuffer();
+ // 閬嶅巻map
+ for (Object obj : map.keySet()) {
+ if (obj == null) {
+ continue;
+ }
+ Object key = obj;
+ Object value = map.get(key);
+ if (value instanceof List<?>) {
+ sb.append(key.toString() + SEP1 + ListToString((List<?>) value));
+ sb.append(SEP2);
+ } else if (value instanceof Map<?, ?>) {
+ sb.append(key.toString() + SEP1
+ + MapToString((Map<?, ?>) value));
+ sb.append(SEP2);
+ } else {
+ sb.append(key.toString() + SEP3 + value.toString());
+ sb.append(SEP2);
+ }
+ }
+ return "M" + sb.toString();
+ }
+
}
--
Gitblit v1.8.0