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;
    }

 

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