Problems reading file from Applet

M

Marcus P

Hello!
I use J2skd 1.4.2 on windows 2000.
I try to read text from a .txt-file on the same server as my applet with the
following code:
int character;
BufferedInputStream bin;
try{
URL fil= new URL("URLToMyTextfile");
bin= (BufferedInputStream)fil.getContent();
while((character=bin.read())>0)
presenteradText=presenteradText+((char)character).toString;
}
catch(MalformedURLException e){
System.out.println(e);
}
catch(IOException ioe){
System.out.println(ioe);
}

presenteradText ia a String.

javac compiles the code ok but when I run my applet I get ClassCastException
error.
Please help me with this one!!
Many thanks in advance!!
Marcus
 
T

The Abrasive Sponge

Marcus said:
Hello!
I use J2skd 1.4.2 on windows 2000.
I try to read text from a .txt-file on the same server as my applet with the
following code:
int character;
BufferedInputStream bin;
try{
URL fil= new URL("URLToMyTextfile");
bin= (BufferedInputStream)fil.getContent();
while((character=bin.read())>0)
presenteradText=presenteradText+((char)character).toString;
}
catch(MalformedURLException e){
System.out.println(e);
}
catch(IOException ioe){
System.out.println(ioe);
}

presenteradText ia a String.

javac compiles the code ok but when I run my applet I get ClassCastException
error.
Please help me with this one!!
Many thanks in advance!!
Marcus
getContent() only returns an InputStream.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top