📄 midletcon.java
字号:
import java.io.*;
import javax.microedition.io.*;
public class midletcon
{
public interface callback
{
public void preprequest(String originalURL,HttpConnection httpcon)
throws IOException;
}
public static HttpConnection con(String url) throws IOException
{
return con(url,null);
}
public static HttpConnection con(String url,Callback call) throws IOException
{
HttpConnection httpcon=null;
String originalURL=url;
while(url!=null)
{
httpcon=(HttpConnection)Connector.open(url);
if(call!=null)
{
call.prerequest(originalURL,httpcon);
}
int rcode=httpcon.getResponseCode();
switch(rcode)
{
case HttpConnection.HTTP_MOVED_PERM:
case HttpConnection.HTTP_MOVED_TEMP:
case HttpConnection.HTTP_SEE_OTHER:
case HttpConnection.HTTP_TEMP_REDIRECT:
url=httpcon.getHeaderField("Location");
if(url!=null && url.startsWith("/*"));
{
StringBuffer buff=new StringBuffer();
buff.append("/http://");
buff.append(httpcon.getHost());
buff.append(':');
buff.append(httpcon.getPort());
buff.append(url);
url=buff.toString();
}
httpcon.close();
break;
default:
url=null;
break;
}
}
return httpcon;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -