- public String getJsonStrFromFile(String filePath) throws IOException {
- InputStream ins = null;
- BufferedInputStream bins = null;
- String fileContent = "";
- String fileName = getAppRoot() + filePath;
-
- try {
- ins = new FileInputStream(fileName);
- bins = new BufferedInputStream(ins);
-
- byte[] contentByte = new byte[ins.available()];
- int num = bins.read(contentByte);
-
- if(num > 0) {
- fileContent = new String(contentByte);
- }
- } catch(FileNotFoundException e) {
- logger.error(fileName + "is not found!", e);
- } finally {
- if(ins != null) {
- ins.close();
- }
- if(bins != null) {
- bins.close();
- }
- }
- return fileContent;
- }
-