Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Benchmark/PVDetails.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
37 lines (32 sloc)
1.15 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Benchmark; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.net.URL; | |
import java.nio.charset.Charset; | |
import org.json.JSONArray; | |
import org.json.JSONObject; | |
public class PVDetails { | |
public static JSONObject getPVDetails(String archapplDomain, String pvName, String query) throws IOException { | |
String url = "http://" + archapplDomain + ":17665/mgmt/bpl/getPVDetails?pv=" + pvName; | |
InputStream is = new URL(url).openStream(); | |
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); | |
StringBuilder sb = new StringBuilder(); | |
String inputLine; | |
while ((inputLine = rd.readLine()) != null) { | |
sb.append(inputLine); | |
} | |
String jsonString = sb.toString(); | |
JSONArray jsonArray = new JSONArray(jsonString); | |
is.close(); | |
JSONObject jo = null; | |
for (Object o : jsonArray) { | |
jo = (JSONObject) o; | |
if ( jo.get("name").toString().equals(query) ) { | |
break; | |
} | |
} | |
return jo; | |
} | |
} |