You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package com.docus.bgts.utils ;
import java.io.* ;
/**
* json工具类
*/
public class JsonUtils {
/**
* 读取json文件方法
* @param fileName: json文件存在的本地地址
* @return
*/
public static String readJsonFile ( String fileName ) {
String jsonStr = "" ;
Reader reader = null ;
FileReader fileReader = null ;
try {
File jsonFile = new File ( fileName ) ;
fileReader = new FileReader ( jsonFile ) ;
reader = new InputStreamReader ( new FileInputStream ( jsonFile ) , "utf-8" ) ;
int ch = 0 ;
StringBuffer sb = new StringBuffer ( ) ;
while ( ( ch = reader . read ( ) ) ! = - 1 ) {
sb . append ( ( char ) ch ) ;
}
fileReader . close ( ) ;
reader . close ( ) ;
jsonStr = sb . toString ( ) ;
return jsonStr ;
} catch ( IOException e ) {
e . printStackTrace ( ) ;
return null ;
} finally {
try {
reader . close ( ) ;
fileReader . close ( ) ;
} catch ( IOException e ) {
e . printStackTrace ( ) ;
}
}
}
}