毕设进度(11.04)

今日搭建了基础的页面结构,进行了上传功能的编写


    @PostMapping("/upload")
    @ResponseBody
    public Result<?> uploadFile(@RequestPart MultipartFile file,
                                @RequestParam(defaultValue = "\t") String partten){
        String filename = file.getOriginalFilename();
        BufferedReader reader = null;
        File realfile = null;
        String temp = null;
        ArrayList<HashMap<String,String>> list = new ArrayList<>();
        try {
            reader = new BufferedReader(new InputStreamReader(file.getInputStream()));
            while ((temp = reader.readLine())!=null){
                String[] strings = temp.split(partten);
                HashMap<String,String> child = new HashMap<>();
                for (int i = 0; i < strings.length; i++) {
                    child.put("a" + (i+1),strings[i]);
                }
                list.add(child);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return Result.success(list);
    }



posted @ 2021-11-04 16:32  Nevesettle  阅读(33)  评论(0编辑  收藏  举报