Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
280 | ligi | 1 | /*************************************************************** |
2 | * |
||
3 | * Helper functions for DUBwise |
||
4 | * |
||
5 | * Author: Marcus -LiGi- Bueschleb |
||
6 | * Mailto: LiGi @at@ LiGi DOTT de |
||
7 | * |
||
8 | ***************************************************************/ |
||
9 | |||
10 | |||
11 | import java.io.*; |
||
12 | import javax.microedition.io.*; |
||
13 | |||
14 | public final class InstallHelper |
||
15 | { |
||
16 | public final static String get_http_string(String url) |
||
17 | { |
||
18 | |||
19 | try { |
||
20 | |||
21 | InputStream stream = null; |
||
22 | StringBuffer buff = new StringBuffer(); |
||
23 | StreamConnection conn=null; |
||
24 | |||
25 | System.out.println("starting conn"); |
||
26 | conn = (StreamConnection)Connector.open(url); |
||
27 | stream = conn.openInputStream(); |
||
28 | int ch; |
||
29 | |||
30 | while((ch = stream.read()) != -1) |
||
31 | buff.append((char) ch); |
||
32 | |||
33 | if(stream != null) |
||
34 | stream.close(); |
||
35 | |||
36 | if(conn != null) |
||
37 | conn.close(); |
||
38 | |||
39 | |||
40 | return buff.toString(); |
||
41 | |||
42 | } |
||
43 | catch ( Exception e) |
||
44 | { |
||
45 | return "err"; |
||
46 | } |
||
47 | |||
48 | } |
||
49 | |||
50 | |||
51 | static public String urlEncode(String sUrl) |
||
52 | { |
||
53 | StringBuffer urlOK = new StringBuffer(); |
||
54 | for(int i=0; i<sUrl.length(); i++) |
||
55 | { |
||
56 | char ch=sUrl.charAt(i); |
||
57 | switch(ch) |
||
58 | { |
||
59 | case '\n': urlOK.append("%0A"); break; |
||
60 | case '-': urlOK.append("%2D"); break; |
||
61 | case '<': urlOK.append("%3C"); break; |
||
62 | case '>': urlOK.append("%3E"); break; |
||
63 | case '/': urlOK.append("%2F"); break; |
||
64 | case ' ': urlOK.append("%20"); break; |
||
65 | case ':': urlOK.append("%3A"); break; |
||
66 | |||
67 | default: urlOK.append(ch); break; |
||
68 | } |
||
69 | } |
||
70 | return urlOK.toString(); |
||
71 | } |
||
72 | } |