java对文件的操作
头像不是我啊
小码农
展开
-
删除 文件
/** * 删除空目录 * * @param dir 将要删除的目录路径 */ public static void deleteEmptyDir(String dir) { boolean success = (new File(dir)).delete(); if (success) { System.out.println("Successfully deleted empty direct...原创 2021-11-17 09:58:01 · 238 阅读 · 0 评论 -
压缩视频文件
/** * 传视频File对象,返回压缩后File对象信息 * * @param source */ public File compressionVideo(File source) { if (source == null) { return null; } File dirFile = new File(uploadPicturePath); if (!dir...原创 2021-10-09 09:12:02 · 73 阅读 · 0 评论 -
读取Excel文件
public Response<String> readWzExcel(MultipartFile file) { //文件存在判断 if (file == null) { return Response.fail("请选择文件"); } //文件名称 String filename = file.getOriginalFilename(); Workbook exc...原创 2021-10-09 09:08:43 · 63 阅读 · 0 评论 -
读取txt文件
public Response<String> readWzTxt(MultipartFile file) { List<String> list = new ArrayList<>(); if (file != null) { try { BufferedReader br = new BufferedReader(new InputStreamReader(file.get...原创 2021-10-09 09:07:53 · 209 阅读 · 0 评论 -
文件-下载
/** *@Description: 文件下载 *@Params: *@Return: */ public static HttpServletResponse downLoadFile(String path,HttpServletResponse response) { try { // path是指下载的文件的路径。 File file = new File(path); ...原创 2021-10-09 08:58:02 · 51 阅读 · 0 评论 -
文件-上传
/** * @param file 文件 * @param path 文件存放路径 * @param fileName 保存的文件名 * @return */ public static boolean upload(MultipartFile file, String path, String fileName) { //确定上传的文件名 Path realPath = Paths.get(p...原创 2021-10-09 08:56:43 · 56 阅读 · 0 评论 -
文件上传
前后端分离且跨域的情况下 form表单提交数据,且数据中包含文件提交上传 1.前端用formdata()的方式提交 let form=document.getElementById('form') var param = new FormData(form); let config = { //添加请求头 headers: { 'Content-Type':'multipart/form-data'} }; // 拿到file console.log转载 2021-08-27 15:07:01 · 52 阅读 · 0 评论