獲取springboot 項目resources文件下的資源

        //獲取resources下面的資源,並進行copy
//        方式1
//        ClassPathResource classPathResource = new ClassPathResource("static/libs/1.png");
//        InputStream inputStream = classPathResource.getInputStream();
//         方式二
        File file = ResourceUtils.getFile("classpath:static/libs/1.png");
        InputStream inputStream = new FileInputStream(file);
        OutputStream outputStream = new FileOutputStream(new File("D:\\upload\\logo\\2.png"));
        IOUtils.copy(inputStream, outputStream);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章