android开发怎么把明文转换为密文
答案:1 悬赏:0 手机版
解决时间 2021-11-25 00:55
- 提问者网友:回忆在搜索
- 2021-11-24 18:43
android开发怎么把明文转换为密文
最佳答案
- 五星知识达人网友:几近狂妄
- 2021-11-24 19:36
public static void saveFile(String toSaveString, String filePath) { try { File saveFile = new File(filePath); if (!saveFile.exists()) { File dir = new File(saveFile.getParent()); dir.mkdirs(); saveFile.createNewFile(); } FileOutputStream outStream = new FileOutputStream(saveFile); outStream.write(toSaveString.getBytes()); outStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public static String readFile(String filePath) { String str = ""; try { File readFile = new File(filePath); if(!readFile.exists()) { return null; } FileInputStream inStream = new FileInputStream(readFile); ByteArrayOutputStream stream = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int length = -1; while ((length = inStream.read(buffer)) != -1) { stream.write(buffer, 0, length); } str = stream.toString(); stream.close(); inStream.close(); return str; } catch (FileNotFoundException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } }
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯