| | |
| | | package org.springblade.modules.FTP; |
| | | |
| | | |
| | | import org.springblade.common.config.FtpConfig; |
| | | |
| | | import java.io.*; |
| | | |
| | | public class OutJson { |
| | |
| | | * 读取json文件并解析 |
| | | * @return |
| | | */ |
| | | public static String TestJson(){ |
| | | File file = new File("D:\\anbao\\sql.json"); |
| | | public static String TestJson(String fileName){ |
| | | //File file = new File(FtpConstant.jsonUrl+fileName); |
| | | File file = new File(FtpConfig.jsonUrl+fileName); |
| | | StringBuilder localStrBulider = new StringBuilder(); |
| | | if(file.isFile() && file.exists()) { |
| | | try { |
| | | InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(file), "utf-8"); |
| | | BufferedReader bufferReader = new BufferedReader(inputStreamReader); |
| | | String lineStr = null; |
| | | try { |
| | | while((lineStr = bufferReader.readLine()) != null) { |
| | | localStrBulider.append(lineStr); |
| | | } |
| | | bufferReader.close(); |
| | | inputStreamReader.close(); |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | System.out.println("file read error!"); |
| | | e.printStackTrace(); |
| | | } |
| | | } catch (UnsupportedEncodingException e) { |
| | | // TODO Auto-generated catch block |
| | | System.out.println("file catch unsupported encoding!"); |
| | | e.printStackTrace(); |
| | | } catch (FileNotFoundException e) { |
| | | // TODO Auto-generated catch block |
| | | System.out.println("file not found!"); |
| | | e.printStackTrace(); |
| | | } |
| | | }else { |
| | | System.out.println("file is not a file or file is not existing!"); |
| | | } |
| | | return localStrBulider.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 读取json文件并解析 |
| | | * @return |
| | | */ |
| | | public static String TestJsons(String urls){ |
| | | File file = new File(urls); |
| | | StringBuilder localStrBulider = new StringBuilder(); |
| | | if(file.isFile() && file.exists()) { |
| | | try { |