Below is the java source code where I am trying to read a file and want to display its content on an applet which is opened through a html page. The problem is that when I try to open the applet through appletviewer there is not problem the data is displayed successfully but the same does not happens then I open the applet through the browser. I am not getting what is the problem in opening the same file through browser. Please help... Following is the code for "" file:

import java.applet.*;
import java.awt.*;
import java.util.Scanner;

public class fileapplet extends Applet
    public void paint(Graphics g)
        BufferedReader diskInput;
        String word;
                int a=0,b=0;  
            //reads in words from a file
            diskInput = new BufferedReader(new InputStreamReader(new FileInputStream("Tree.txt")));
            // file name is on command line
            Scanner input=new Scanner(diskInput);

                while (input.hasNext()) 
                    word=word.toLowerCase(); // use lower case only
        catch (IOException e) 

Following is the code for "fileapplet.html":

<applet code="fileapplet.class" width="100" height="100">
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.