- 博客(6)
- 收藏
- 关注
原创 Android studio 向手机存储写入txt内容
//path: 路径//Msg: 要写入的内容//isCover: 是否覆盖原有内容, true 覆盖, false 新增public static boolean writeFile(String path, String Msg, boolean isCover) {try {File file = new File(path);if (file.isDirectory()) {...
2020-04-14 23:22:06
3374
原创 Android studio 读取txt文件内容
//读取txt文件, 返回值永远不为null//注意要有存储权限public static String readFile(String path) {String result;try {File file = new File(path);//先读取info.txtif (!file.exists()) {return “”;}int length = (int) file....
2020-04-14 23:11:12
3051
原创 Android studio 获取SD卡根目录
//获取 SD 卡路径//注意: 最后有///注意: 从 Android 5.0 Lollipop 开始(SD卡只能读不能写)//注意添加存储权限////public static String getSdcardRootPath(Context context) {try {StorageManager storageManager = (StorageManager) cont...
2020-04-14 23:07:33
2723
原创 Android studio 获取一个随机数
获取一个随机数, 取值在 min--max 之间包括 min 和 maxpublic static int random(int min, int max) { if (min > max) { return (int) (max + (min - max + 1) * Math.random()); } return (int) (min + (m...
2020-04-14 22:59:36
2249
原创 Android studio 获取两数最大公约数
废话不多说, 直接给代码public static int getGreatestCommonNum(int a, int b) {if (a == b) {if (a == 0)return 1;elsereturn a;}int small = Math.min(a, b);if(small == 0)return 1;int big = Math.max(a, b);...
2020-04-14 22:51:57
436
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人