|
|
@ -171,7 +171,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
* @return JSONObject数据 |
|
|
|
* @return JSONObject数据 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun getAsJSONObject(key: String): JSONObject? { |
|
|
|
fun getAsJSONObject(key: String): JSONObject? { |
|
|
|
val json = getAsString(key) |
|
|
|
val json = getAsString(key) ?: return null |
|
|
|
return try { |
|
|
|
return try { |
|
|
|
JSONObject(json) |
|
|
|
JSONObject(json) |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
@ -311,17 +311,17 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) |
|
|
|
fun getAsObject(key: String): Any? { |
|
|
|
fun getAsObject(key: String): Any? { |
|
|
|
val data = getAsBinary(key) |
|
|
|
val data = getAsBinary(key) |
|
|
|
if (data != null) { |
|
|
|
if (data != null) { |
|
|
|
var bais: ByteArrayInputStream? = null |
|
|
|
var bis: ByteArrayInputStream? = null |
|
|
|
var ois: ObjectInputStream? = null |
|
|
|
var ois: ObjectInputStream? = null |
|
|
|
try { |
|
|
|
try { |
|
|
|
bais = ByteArrayInputStream(data) |
|
|
|
bis = ByteArrayInputStream(data) |
|
|
|
ois = ObjectInputStream(bais) |
|
|
|
ois = ObjectInputStream(bis) |
|
|
|
return ois.readObject() |
|
|
|
return ois.readObject() |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
e.printStackTrace() |
|
|
|
e.printStackTrace() |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
try { |
|
|
|
try { |
|
|
|
bais?.close() |
|
|
|
bis?.close() |
|
|
|
} catch (e: IOException) { |
|
|
|
} catch (e: IOException) { |
|
|
|
e.printStackTrace() |
|
|
|
e.printStackTrace() |
|
|
|
} |
|
|
|
} |
|
|
|