소스 검색

获取文件路径

chengqiang 2 년 전
부모
커밋
c421f1c3b1
1개의 변경된 파일4개의 추가작업 그리고 10개의 파일을 삭제
  1. 4 10
      src/main/java/com/jeeplus/modules/cg/reservemanagementcenter/reserveManage/web/ProcessController.java

+ 4 - 10
src/main/java/com/jeeplus/modules/cg/reservemanagementcenter/reserveManage/web/ProcessController.java

@@ -163,17 +163,11 @@ public class ProcessController extends BaseController {
             demoliteService.deleteByProjectReserveId(projectReserveId);
             //获取拆旧清册数据
             File file = new File(reserveProcess.getDemolition());
-            System.out.println("file.getAbsolutePath():" + file.getAbsolutePath());
-//            String path = file.getAbsolutePath().replace("\\a", "");
             String path = file.getAbsolutePath();
-            String newPath = "";
-            for (int i=0;i<path.length();i++){
-                if (i<2 || i>=4){
-                    newPath += path.charAt(i);
-                }
-            }
-            System.out.println("newPath: " + newPath);
-            File demoFile = new File(newPath);
+            int index = file.getAbsolutePath().indexOf("\\fileServer");
+            path = path.substring(index);
+
+            File demoFile = new File(path);
 
             InputStream inputStream = new FileInputStream(demoFile);
             MultipartFile multipartFile = new MockMultipartFile("file", demoFile.getName(), null, inputStream);