Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reading a URL

 
suman racha
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write an applet that reads a text file over a unix network and creates a GUI from the info. in that file.
I am getting a security exception. how do I make it to read the file? do I need to install a security manager? help me out.
thanks.
 
Raghavendra Holla
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
check out if this helps you?
StringBuffer getFile(String Url)
{
String Url=this.Url;
StringBuffer s=new StringBuffer();
try
{
URL url=new URL(Url);
URLConnection con=url.openConnection();
BufferedInputStream in=new BufferedInputStream(con.getInputStream());
int n;
while((n=in.read())!=-1)
{
s.append((char)n);
}
in.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return s;
}
 
suman racha
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it doesn't work raghav, because the applet is not able to initiate a contact with the URL in the first place. that is where I am getting the network security exception.
 
Raghavendra Holla
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you able to open URL in browser? If yes surly this code works. We are using this code for one such purposes.
regards.
holla
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic