net 调用java 接口方式
private const string CST_DEFAULT_ENCODEING = "GB2312" ;
public static string GetWebPageString(string URL)
{
Stream data = null ;
try
{
string str = "";
string sReturn = "" ;
// Get HTML data
WebClient client = new WebClient();
data = client.OpenRead(URL);
StreamReader reader = new StreamReader(data, System.Text.Encoding.GetEncoding (CST_DEFAULT_ENCODEING) );
str = reader.ReadLine();
while( str != null)
{
sReturn += str ;
str = reader.ReadLine();
}
return sReturn;
}
catch(WebException exp)
{
Debug.WriteLine(exp.Message, "WebException");
throw exp;
}
catch(Exception ex)
{
throw ex;
}
finally
{
if (data != null) data.Close () ;
}
}
浙公网安备 33010602011771号