private boolean loginDomino(String strHost,String strUserName,String strPassWord)
{
boolean strReturn = false;
String strNSF = "/names.nsf";
String strLoginTarget = "";
URL mURL = null;
URLConnection uc = null;
InputStream content = null;
BufferedReader buffer = null; try
{
String strResult = "";
mURL = new URL("http://" + strHost + strNSF + "?Login&username=" + strUserName + "&password=" + strPassWord);
uc = mURL.openConnection();
content = (InputStream)uc.getInputStream();
buffer = new BufferedReader(new InputStreamReader(content));
mURL = new URL("http://" + strHost + strNSF + strLoginTarget);
buffer = new BufferedReader(new InputStreamReader(mURL.openStream()));
showInfo(mURL.toString());
for(int i = 1;i < 10;i++)
{
strResult = buffer.readLine();
showInfo(strResult);
if(strResult != null)
{
if(strResult.equals("0"))
{
showInfo("No." + i + "!");
showInfo("Login Success !");
strFullName = buffer.readLine();
strReturn = true;
break;
}
}
}
buffer.close();
content.close();
uc = null;
mURL = null;
}
catch(Exception e)
{
//e.printStackTrace();
try
{
if(buffer != null)
{
buffer.close();
}
if(content != null)
{
content.close();
}
uc = null;
mURL = null;
}
catch(Exception e_Err)
{
e_Err.printStackTrace();
}
showInfo("Login Domino " + strHost + " Error!");
}
return strReturn;
}
{
boolean strReturn = false;
String strNSF = "/names.nsf";
String strLoginTarget = "";
URL mURL = null;
URLConnection uc = null;
InputStream content = null;
BufferedReader buffer = null; try
{
String strResult = "";
mURL = new URL("http://" + strHost + strNSF + "?Login&username=" + strUserName + "&password=" + strPassWord);
uc = mURL.openConnection();
content = (InputStream)uc.getInputStream();
buffer = new BufferedReader(new InputStreamReader(content));
mURL = new URL("http://" + strHost + strNSF + strLoginTarget);
buffer = new BufferedReader(new InputStreamReader(mURL.openStream()));
showInfo(mURL.toString());
for(int i = 1;i < 10;i++)
{
strResult = buffer.readLine();
showInfo(strResult);
if(strResult != null)
{
if(strResult.equals("0"))
{
showInfo("No." + i + "!");
showInfo("Login Success !");
strFullName = buffer.readLine();
strReturn = true;
break;
}
}
}
buffer.close();
content.close();
uc = null;
mURL = null;
}
catch(Exception e)
{
//e.printStackTrace();
try
{
if(buffer != null)
{
buffer.close();
}
if(content != null)
{
content.close();
}
uc = null;
mURL = null;
}
catch(Exception e_Err)
{
e_Err.printStackTrace();
}
showInfo("Login Domino " + strHost + " Error!");
}
return strReturn;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货