- 博客(4)
- 资源 (1)
- 收藏
- 关注
原创 java 为文件及文件夹添加权限
/** * 增加权限,使路径可上传文件 */public static void addChmod777(String filePath) throws IOException { if (!System.getProperty("os.name").startsWith("Win")) { String cmdGrant = "chmod 777 " + filePath; Ba...
2019-11-28 15:51:09
3875
原创 java 将目录中多个斜杠转换为1个
public static String transformPath(String path) {String regex = “/+”;String regex1 = “\\+”;return path.replaceAll(regex, “/”).replaceAll(regex1, “/”);}
2019-11-28 15:49:18
747
原创 jdk1.8 转化时间格式为:yyyy-MM-dd'T'HH:mm:ss'Z'
import java.time.ZoneId;import java.time.ZonedDateTime;import java.time.format.DateTimeFormatter;DateTimeFormatter formatter0 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.sy...
2019-10-25 09:31:43
3257
原创 java 获得文件大小并转换为MB
//不能直接进行运算,会损失精度,因此先取得大小double fileSize = file.length();//运算转换单位(保留2位小数)double fileSizeMB = new BigDecimal(fileSize/1024/1024).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); //转换单位为MB...
2019-10-25 09:17:34
4177
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人