Blame |
Last modification |
View Log
| RSS feed
/***************************************************************
*
* Helper functions for DUBwise
*
* Author: Marcus -LiGi- Bueschleb
* Mailto: LiGi @at@ LiGi DOTT de
*
***************************************************************/
import java.io.*;
import javax.microedition.io.*;
public final class InstallHelper
{
public final static String get_http_string
(String url
)
{
try {
InputStream stream =
null;
StringBuffer buff =
new StringBuffer();
StreamConnection conn=
null;
System.
out.
println("starting conn");
conn =
(StreamConnection
)Connector.
open(url
);
stream = conn.
openInputStream();
int ch
;
while((ch = stream.
read()) != -
1)
buff.
append((char) ch
);
if(stream
!=
null)
stream.
close();
if(conn
!=
null)
conn.
close();
return buff.
toString();
}
catch ( Exception e
)
{
return "err";
}
}
static public String urlEncode
(String sUrl
)
{
StringBuffer urlOK =
new StringBuffer();
for(int i=
0; i
<sUrl.
length(); i++
)
{
char ch=sUrl.
charAt(i
);
switch(ch
)
{
case '\n': urlOK.
append("%0A"); break;
case '-': urlOK.
append("%2D"); break;
case '<': urlOK.
append("%3C"); break;
case '>': urlOK.
append("%3E"); break;
case '/': urlOK.
append("%2F"); break;
case ' ': urlOK.
append("%20"); break;
case ':': urlOK.
append("%3A"); break;
default: urlOK.
append(ch
); break;
}
}
return urlOK.
toString();
}
}