• properties文件导出


      功能要求根据数据库记录的key-value-remark 数据,导出保存properties文件

      1. pro.load()  pro.list() 处理不能解决备注、排序问题

      2. 最后考虑下什么是properties文件,操作系统大概怎么区分这样的数据是正确的properties数据,区分大概回车符与#符,直接拼接字符,输入输出流导出

          

    @RequestMapping(value = "/export/{id}", method = RequestMethod.GET)
        public void export(@PathVariable("id") Long id) throws IOException {
            response.reset();
            StringBuilder buff = new StringBuilder();
        
            AppProperties tc = appPropertiesService.get(id);
            String fileName = tc.getLineCode()+tc.getAppCode()+tc.getId();
            if(tc != null){
                Collection<SearchFilter> filters = new ArrayList<>();
                filters.add(new SearchFilter("refId",SearchFilter.Operator.valueOf("EQ"),id));
                List<PropertiesInfo> detailList = propertiesInfoService.findAll(new SearchSpecification(filters,PropertiesInfo.class) , new Sort(Sort.Direction.ASC,new String[]{"orderBy"}));
                for(PropertiesInfo info:detailList){
                    if(info.getRemark() != null && !"".equals(info.getRemark())){
                        buff.append("#").append(info.getRemark()).append("
    ");
                    }
                    buff.append(info.getKey()).append("=").append(info.getValue()).append("
    ");
                    
                }
            } 
    
            response.setHeader("Content-Disposition", "attachment;filename="+fileName+".properties");
            response.setContentType("application/msexcel; charset=GBK");
            ServletOutputStream out = response.getOutputStream();
            
            BufferedInputStream br = new BufferedInputStream(new ByteArrayInputStream(buff.toString().getBytes()));  
            byte[] buf = new byte[1024];
            int len = 0;   
    
            while ((len = br.read(buf)) > 0){
                out.write(buf, 0, len);  
            }  
            out.flush();
            br.close(); 
            out.close();
    
        }

      

      

  • 相关阅读:
    Tensorflow
    EM算法
    神经网络 CNN
    神经网络总结(tensorflow)
    Chrome扩展程序和油猴推荐
    机器学习(贝叶斯,K-means,ROC,AUC)
    机器学习随笔(决策树,集成算法,交叉验证)
    机器学习随笔(线性回归,逻辑回归原理)
    @PropertySource加载文件的两种用法以及配置文件加载顺序
    JNDI(Java Naming and Directory Interface )
  • 原文地址:https://www.cnblogs.com/ks-apper/p/5157817.html
Copyright © 2020-2023  润新知