E
emildy
Unregistered / Unconfirmed
GUEST, unregistred user!
public String get(String s, boolean isGZIP){
byte[] data = new byte[0];
try{
URL url = new URL(s);
URLConnection urlconnection = url.openConnection();
urlconnection.connect();
InputStream inputstream = urlconnection.getInputStream();
if(isGZIP){
GZIPInputStream gzipinputstream = new GZIPInputStream(inputstream);
inputstream = gzipinputstream;
}
int buffsize = 1024;
byte[] buff = new byte[buffsize];
int i = 0;
int j = 0;
while(j != -1){
j = inputstream.read(buff,0,buffsize);
if(j==-1){break;}
byte[] datacp = data;
data = new byte[j+datacp.length];
System.arraycopy(datacp,0,data,0,datacp.length);
System.arraycopy(buff,0,data,datacp.length,j);
}
}catch(IOException e){}
return new String(data);
}
以上是我放在Applet中的一个方法,但是总是出现这样的错误:
com.ms.security.SecurityExceptionEx[com/stockway/chart/AppMain.getHttpData]: cannot access "192.168.0.1":80
--at com/ms/security/permissions/NetIOPermission.check
--at com/ms/security/PolicyEngine.deepCheck
--at com/ms/security/PolicyEngine.checkPermission
--at com/ms/net/wininet/WininetURLConnection.checkSecurity
--at com/ms/net/wininet/WininetURLConnection.connect
--at com/ms/net/wininet/WininetURLConnection.getInputStream
--at java/net/URL.openStream
--at com/stockway/chart/AppMain.getHttpData
--at com/stockway/chart/AppMain$5.mouseClicked
--at java/awt/AWTEventMulticaster.mouseClicked
--at java/awt/Component.processMouseEvent
--at java/awt/Component.processEvent
--at java/awt/Container.processEvent
--at java/awt/Component.dispatchEventImpl
--at java/awt/Container.dispatchEventImpl
--at java/awt/Component.dispatchEvent
--at java/awt/EventDispatchThread.run
但是,我单独调试这个方法,是可以正常运行的,为什么放在我的Applet中就不行了呢?
请高手帮帮我吧...
byte[] data = new byte[0];
try{
URL url = new URL(s);
URLConnection urlconnection = url.openConnection();
urlconnection.connect();
InputStream inputstream = urlconnection.getInputStream();
if(isGZIP){
GZIPInputStream gzipinputstream = new GZIPInputStream(inputstream);
inputstream = gzipinputstream;
}
int buffsize = 1024;
byte[] buff = new byte[buffsize];
int i = 0;
int j = 0;
while(j != -1){
j = inputstream.read(buff,0,buffsize);
if(j==-1){break;}
byte[] datacp = data;
data = new byte[j+datacp.length];
System.arraycopy(datacp,0,data,0,datacp.length);
System.arraycopy(buff,0,data,datacp.length,j);
}
}catch(IOException e){}
return new String(data);
}
以上是我放在Applet中的一个方法,但是总是出现这样的错误:
com.ms.security.SecurityExceptionEx[com/stockway/chart/AppMain.getHttpData]: cannot access "192.168.0.1":80
--at com/ms/security/permissions/NetIOPermission.check
--at com/ms/security/PolicyEngine.deepCheck
--at com/ms/security/PolicyEngine.checkPermission
--at com/ms/net/wininet/WininetURLConnection.checkSecurity
--at com/ms/net/wininet/WininetURLConnection.connect
--at com/ms/net/wininet/WininetURLConnection.getInputStream
--at java/net/URL.openStream
--at com/stockway/chart/AppMain.getHttpData
--at com/stockway/chart/AppMain$5.mouseClicked
--at java/awt/AWTEventMulticaster.mouseClicked
--at java/awt/Component.processMouseEvent
--at java/awt/Component.processEvent
--at java/awt/Container.processEvent
--at java/awt/Component.dispatchEventImpl
--at java/awt/Container.dispatchEventImpl
--at java/awt/Component.dispatchEvent
--at java/awt/EventDispatchThread.run
但是,我单独调试这个方法,是可以正常运行的,为什么放在我的Applet中就不行了呢?
请高手帮帮我吧...