MCPcopy Index your code
hub / github.com/amadeus4dev/amadeus-java / readBody

Method readBody

src/main/java/com/amadeus/Response.java:127–155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

125
126 // Tries to read the body.
127 private String readBody() {
128 // Get the connection
129 HttpURLConnection connection = getRequest().getConnection();
130
131 // Try to get the input stream
132 InputStream inputStream = null;
133 try {
134 inputStream = connection.getInputStream();
135 } catch (IOException e) {
136 inputStream = connection.getErrorStream();
137 }
138
139 // Try to parse the input stream
140 try {
141 InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
142 BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
143 StringBuffer body = new StringBuffer();
144 String inputLine;
145 while ((inputLine = bufferedReader.readLine()) != null) {
146 body.append(inputLine);
147 }
148 bufferedReader.close();
149 // Return the response body
150 return body.toString();
151 } catch (IOException e) {
152 // return null if we could not parse the input stream
153 return null;
154 }
155 }
156
157 // Ties to parse the response body into a JSON Object
158 private JsonObject parseJson() {

Callers 1

parseDataMethod · 0.95

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected