Skapat ett nytt paket (com.lil.om) med en ny klass (Utils) som
innehåller en enkel wget metod som kan anropas för att hämta en url och få resultatet som en sträng. Denna kan användas från en SiteScope Custom Monitor för att göra ett REST anrop mot OraMonREST.
Showing
7 changed files
with
30 additions
and
1 deletions
JavaMON/.gitignore
0 → 100644
1 | /ThumbnailsCache.tmp |
No preview for this file type
No preview for this file type
LILOM Library/com/lil/om/.gitignore
0 → 100644
1 | /Utils.class |
LILOM Library/com/lil/om/Utils.java
0 → 100644
1 | package com.lil.om; | ||
2 | |||
3 | import java.io.BufferedReader; | ||
4 | import java.io.InputStreamReader; | ||
5 | import java.net.URL; | ||
6 | import java.net.URLConnection; | ||
7 | |||
8 | public class Utils { | ||
9 | public String wget(String urlToGet) { | ||
10 | // Simple class that gets a URL and returns the contents as as string | ||
11 | StringBuffer sb = new StringBuffer(); | ||
12 | try { | ||
13 | URL url = new URL(urlToGet); | ||
14 | URLConnection yc = url.openConnection(); | ||
15 | BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream())); | ||
16 | String inputLine; | ||
17 | while ((inputLine = in.readLine()) != null) | ||
18 | sb.append(inputLine); | ||
19 | in.close(); | ||
20 | } catch (Exception e) { | ||
21 | return e.getMessage(); | ||
22 | } | ||
23 | return sb.toString(); | ||
24 | } | ||
25 | } |
-
Please register or sign in to post a comment