| | |
| | | package com.moral.api.utils; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.io.Reader; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.core.io.Resource; |
| | | |
| | | import java.io.*; |
| | | |
| | | public class JsonUtil { |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public static String testReadFile(String filePath) throws IOException { |
| | | // ClassPathResource classPathResource = new ClassPathResource("resource.properties"); |
| | | String jsonStr = ""; |
| | | Resource resource = new ClassPathResource(filePath); |
| | | InputStream is = resource.getInputStream(); |
| | | Reader reader = new InputStreamReader(resource.getInputStream(), "utf-8"); |
| | | int ch = 0; |
| | | StringBuffer sb = new StringBuffer(); |
| | | while ((ch = reader.read()) != -1) { |
| | | sb.append((char) ch); |
| | | } |
| | | reader.close(); |
| | | jsonStr = sb.toString(); |
| | | return jsonStr; |
| | | } |
| | | |
| | | } |
| | | |