src/main/java/com/company/project/util/FileUtils.java
(完整代码) 1KBpackage com.company.project.util;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
/**
* 文件相关的工具类
*/
public class FileUtils {
/**
* 文件上传
* @param file
* @param filePath 文件路径
* @param fileName 文件名称
* @throws Exception
*/
public static void uploadFile(byte[] file, String filePath, String fileName) throws Exception {
File targetFile = new File(filePath);
if(!targetFile.exists()){
targetFile.mkdirs();
}
FileOutputStream out = new FileOutputStream(filePath+fileName);
out.write(file);
out.flush();
out.close();
}
/**
* 上传文件夹以 yyyy-MM-dd 命名
* @return
*/
public static String getFolder(){
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(new Date());
}
/**
* 产生一个36个字符的UUID
*
* @return UUID
*/
public static String randomUUID() {
return UUID.randomUUID().toString();
}
public static String getOrderNumber(){
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");
return sdf.format(new Date());
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
