It's a GUI interface in java applet. What I want to do is let user input a URL in a TextArea and program will get this URL to retrieve the content of the indicated web page.
source code is:
--------------------------------------------------
if ( str.equals("Submit data source" )
{ if (source.equals("URL")
{
String s = text.getText();
System.out.println("URL:" + s);
try{
Source currentURL = new Source( s );
URL curl = new URL(s);
currentURL.ReadinURL(curl);}
catch (MalformedURLException mal) {
text.setText("Bad URL: " + s);
}
---------------------------------------------------
ReadinURL method in Source class is like this:
public void ReadinURL(URL url)
{//read in a URL and retrieve the cotent from it
InputStream is = null;
int i=0;
try
{
// Get InputStream
is = url.openStream();
Reader reader = new InputStreamReader(is);
BufferedReader br = new BufferedReader(reader);
String line = null;
while ((line = br.readLine()) != null)
{
System.out.println("line" + line);
html = line;
i++;
}
}
catch (IOException ioException)
{
System.err.println("Error processing: " + url);
}
finally
{
if (is != null)
{
try
{ is.close();}
catch (IOException ioException) {}
}
}//end of finally
}
But exception throws when execute it:
java.security.AccessControlException:access denied(java.net.SocketPermission resolve)
Please if you want to know how to solve this problem,please email me jane_duan@yahoo.com I'd very appreciate!
Thanks.
duan
source code is:
--------------------------------------------------
if ( str.equals("Submit data source" )
{ if (source.equals("URL")
{
String s = text.getText();
System.out.println("URL:" + s);
try{
Source currentURL = new Source( s );
URL curl = new URL(s);
currentURL.ReadinURL(curl);}
catch (MalformedURLException mal) {
text.setText("Bad URL: " + s);
}
---------------------------------------------------
ReadinURL method in Source class is like this:
public void ReadinURL(URL url)
{//read in a URL and retrieve the cotent from it
InputStream is = null;
int i=0;
try
{
// Get InputStream
is = url.openStream();
Reader reader = new InputStreamReader(is);
BufferedReader br = new BufferedReader(reader);
String line = null;
while ((line = br.readLine()) != null)
{
System.out.println("line" + line);
html = line;
i++;
}
}
catch (IOException ioException)
{
System.err.println("Error processing: " + url);
}
finally
{
if (is != null)
{
try
{ is.close();}
catch (IOException ioException) {}
}
}//end of finally
}
But exception throws when execute it:
java.security.AccessControlException:access denied(java.net.SocketPermission resolve)
Please if you want to know how to solve this problem,please email me jane_duan@yahoo.com I'd very appreciate!
Thanks.
duan