return longUrl;
}
}
public static String gistText(String text) {
Yaml yaml = YAML_INSTANCE.get();
OutputStreamWriter requestWriter = null;
InputStream responseReader = null;
try {
URLConnection conn = GIST_POST_URL.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
Map<String, Object> request = new HashMap<>(); // {
request.put("description", "PEX Error Report"); // "description": "PEX Error Report",
request.put("public", "false"); // "public": false,
Map<String, Object> filesMap = new HashMap<>(); // "files": {
Map<String, Object> singleFileMap = new HashMap<>(); // "report.md": {
singleFileMap.put("content", text); // "content": <text>
filesMap.put("report.md", singleFileMap); // }
request.put("files", filesMap); // }
// }
yaml.dump(request, (requestWriter = new OutputStreamWriter(conn.getOutputStream())));
Map<?, ?> data = (Map<?, ?>) yaml.load((responseReader = conn.getInputStream()));
if (data.containsKey("html_url")) {
return data.get("html_url").toString();
}
} catch (IOException e) {
e.printStackTrace();