Showing posts with label JSON. Show all posts
Showing posts with label JSON. Show all posts

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 ChatGPT can Benefit Coding: Your Guide to Leveraging an AI Language Model

 Introduction: Hello, coders! Welcome to this blog post on how ChatGPT, an AI language model, can benefit your coding skills and projects. A...