Write an applet that display the directory holding the HTML file that started the applet and the directory from which, applet class file was loaded.
An applet is here given below, which display the directory holding the HTML file which started the applet:
import java.awt .*;
import java.applet .*; //import package
import java.net .*;
public class Base extends Applet
{
public void piant (Graphics g)
{
String msg;
URL url = getCodebase( ); / / string is initialize to be displayed.
Msg = "Code base:" +url . tost ring( );
g.drawst ring(msg,10,20);
URL url = getDocumentbase() ;
Msg = "Document base: " +url . tost ring();
g.drawst ring(msg,10,40);
}
}