Wednesday, January 11, 2017

How to convert JSON file to String

Below method will return String. You need to pass argument file path.



public static String getStringFromInputStream(String filepath) {

         BufferedReader br = null;
         StringBuilder sb = new StringBuilder();

         String line;
         try {
             br = new BufferedReader(new FileReader(filepath));
             while ((line = br.readLine()) != null) {
                 sb.append(line);
             }

         } catch (IOException e) {
             e.printStackTrace();
         } finally {
             if (br != null) {
                 try {
                      br.close();
                 } catch (IOException e) {
                      e.printStackTrace();
                 }
             }
         }

         return sb.toString();


    }

How to Calculate the Future Investment Value of Investment.

Below java program for calculate future investment value. Here calculate s using the formula futureInvestmentValue =investmentAmount x (...