tomcat下創建文件夾存儲文件

    @ResponseBody //請假時間,效驗時間重複  1通過->沒有重複值 0->請假時間重複
    @RequestMapping(value = "/test", method = RequestMethod.GET)
    public String test() {
        String property = System.getProperty("user.dir");
        property=property.substring(0,property.lastIndexOf("\\"));
        SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");
        File file=new File(property+"/webapps/"+sdf.format(new Date()));
        if(!file.exists()){
            file.mkdirs();
        }
        String path = file.getAbsolutePath();
        System.out.println("path===="+path);//tomcat文件夾
        return property;
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章