Problem reading file from applet!

M

Marcus P

Hello!
I'm not too experienced in java and I have a problem reading from a file
with my applet. As I understand the applet is aloud to read from the same
folder as the applet is in.
I have declared a File (that point to my file in the same folder), a
FileReader with try and catch Exception and then I have written
FileReader.read(char c, int, int) with try and catch. The compiler accepts
my code but when I run my applet in appletviewer the promt gives me errors.
Can somebody please help me?
Many, many thanks in advance!
Best regards
Marcus
 
R

Rhino

Marcus P said:
Hello!
I'm not too experienced in java and I have a problem reading from a file
with my applet. As I understand the applet is aloud to read from the same
folder as the applet is in.
I have declared a File (that point to my file in the same folder), a
FileReader with try and catch Exception and then I have written
FileReader.read(char c, int, int) with try and catch. The compiler accepts
my code but when I run my applet in appletviewer the promt gives me errors.
Can somebody please help me?
Many, many thanks in advance!
Best regards
Marcus
You haven't shown us any code nor specified the error messages. That makes
it pretty hard for anyone to help you. It may also be useful to know
something about your environment: which version of Java are you running and
what operating system are you using.

Without more information, there's not much that we can do for you.

Rhino
 
A

Andrew Thompson

The same *host*. That is not the same thing.

With appropriate parameters in the applet element, an applet
can access any file in any (non protected) directory of the
site or disk from which it was delivered.

You need to use URL's to get your data. File related objects
will always hit the applet security sandbox restrictions.
<http://www.physci.org/codes/javafaq.jsp#security>
<http://mindprod.com/jgloss/applet.html#RESTRICTIONS>

Use 'getResource to get an URL..
<http://www.physci.org/pc/property.jsp?prop=java.version+java.vendor>

Then load the bytes from the URL, or hand it to something that will.
You haven't shown us any code

..nor specified the error messages.

..That makes
it pretty hard for anyone to help you. It may also be useful to know
something about your environment: which version of Java are you running
<http://www.physci.org/pc/property.jsp?prop=java.version+java.vendor>

....
Without more information, there's not much that we can do for you.

Spot on. An URL is also handy for applets, especially if they break.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top