java applet using FileReader I/O

I'm currently a TA teaching a class at Lockheed Martin and loooking for a quick source code java applet which reads a information from a txt file using FileReader and displays it to the screen when the button on the applet is pushed.

anyway you have something lying around that I can use as a working example
been busting butt seaching but have found no luck and I have to have this ready tomorrow.
Your help be appreciated Thank You
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BufferedReader in = new BufferedReader(new FileReader(file));
String line = null;
while (null!=(line=in.readLine()))

to read from a local file from an applet will require the applet be signed.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Do something like:

BufferedReader in = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/x.txt")));
String buffer = null;
while ((buffer = in.readLine()) != null) {
you could use a JTextArea to display the file contents to screen.
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

If you put x.txt into the same directory as the applet class file, you won't have to sign the applet
Add the above code to the ActionListener for your button

> If you put x.txt into the same directory as the applet class file, you won't have to sign the applet

you can put it in any directory you want on the server that is visible to the applet.
you need to sign it if want to read files on the *client*.
this may help:

let me know if you have any questions.
If you do need it to read files on the client, here's some info about signing the applet:
Tommy BraasCommented:
Hi angel875,

It would be academic dishonesty to provide you with code outright.

A FileReader can be instantiated with either a String path to a file, a File instance or a FileDescriptor. Once instantiated, it can be read from provided the file exists. If the file doesn't exist a FileNotFoundException will be thrown. See

To display it in an applet, you could add a TextArea to the applet and add the text you read from the file into the text area.

In order to allow an applet to show local file content, the applet needs to be signed. An applet operates in 'sandbox' and it is not allowed to read/write files by default. Please have a look at the following page for a plethora of links
or check this link out directly:

Tommy BraasCommented:
damn, it took too long to write my essay....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.