hi, i have a little problem running my
applet. it's supposed to get a file from the WWW and display its contents as a
string inside a JTextArea. the file on the web is a simple .txt containing little text, say one sentence, its irrelevant here. the file is read in inside a different class that the applet calls. however, there seems to be a problem with that - maybe it has something to do with Applet restrictions. anyway. here goes:
the applet (i removed all irrelevant applet construction objects like buttons etc) -
public class Applet1 extends JApplet {
private JTextArea sisestaJutt;
private String juttVeebist;
public void init() {
URLReader veebist = new URLReader();
try {
juttVeebist.equals( veebist.reader());
}
catch(Exception e) {
}
Container sisu = new Container();
sisestaJutt = new JTextArea(juttVeebist);
sisu = getContentPane();
sisu.setLayout( new BorderLayout() );
sisestaJutt.setBorder(brdr);
sisu.add(sisestaJutt, BorderLayout.CENTER);
}
}
the called class (& method) -
public class URLReader {
public static String reader()
throws Exception {
URL jjstreet = new URL("http://www.anydomain.com/file.txt");
BufferedReader input = new BufferedReader(
new InputStreamReader(
jjstreet.openStream()));
String inputLine = input.readLine();
input.close();
return inputLine;
}
}