//sd卡的路徑
private static final String SD_PATH = Environment
.getExternalStorageDirectory()+"http://notes";
private static final String FILE_NAME="note";
public static void checkDir(){File fileDir=new File(SD_PATH);
if(!fileDir.exists()){fileDir.mkdirs();
}
}
public static Listread(Context context){ // String fileName="innerFile";
checkDir();
FileInputStream fis=null;
StringBuilder builder=null;
try { // fis=context.openFileInput(fileName);
fis=new FileInputStream(new File(SD_PATH,FILE_NAME));
BufferedReader bf=new BufferedReader(new InputStreamReader(fis));
builder=new StringBuilder();
String line=null;
while((line=bf.readLine())!=null){builder.append(line);
}
} catch (IOException e) {e.printStackTrace();
} finally {if (fis != null) {try {fis.close();
} catch (IOException e) {e.printStackTrace();
}
}
}
//使用gson將json字符串轉(zhuǎn)成list
Gson gson=new Gson();
return gson.fromJson(datalist,new TypeToken>(){}.getType());
}
public static void write(Listlist, Context context){ // String fileName="innerFile";
checkDir();
Gson gson=new Gson();
String outData = gson.toJson(list);
FileOutputStream fos=null;
try { // fos=context.openFileOutput(fileName, Context.MODE_PRIVATE);
fos=new FileOutputStream(new File(SD_PATH,FILE_NAME));
if(outData!=null){fos.write(outData.getBytes());
}
fos.flush();
} catch (IOException e) {e.printStackTrace();
} finally {if(fos!=null){try {fos.close();
} catch (IOException e) {e.printStackTrace();
}
}
}
}
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧
長陽ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!