BufferedReader br = new BufferedReader( new InputStreamRead er(s.getInputSt ream()));
BufferedOutputS tream bos = new BufferedOutputS tream(s.getOutp utStream());
//PrintWriter out = new PrintWriter();
String line = br.readLine();
System.out.prin tln(line);
File f = new File(dirname,"i ndex.html");
System.out.prin tln( dirname + " is in run method" );
System.out.prin tln(f.getCanoni calPath());
File[] f2 = f.listFiles();
for(int j =0; j<f.length();j+ +)
{
System.out.prin tln("files are " + f2[j]);
}
/* in this write method i got error i.e in method wrinte(int) in the type BufferedOutputs tream is not applicable for the argument (string)*/
bos.write("HTTP/1.0 200 OK\r\n" +
"Content-Type: text/html\r\n" +
"<h1>Direct ory Listing</h1>" +
"<h3>" + f.getCanonicalP ath() +
"</h3>" + "<table border=\"0\" cellspacing=\"8 \">" +
"<tr><td><b>Fil ename</b><br></td><td align=\"right\" ><b>Size</b></td><td><b>Last Modified</b></td></tr>" +
"<tr><td><b ><a href=\"/\">/</b><br></td><td></td><td></td></tr>").getBytes( );
for(int i=0;i<f2.length ;i++)
{
f = f2[i];
if (f.isDirectory( ))
{
System.out.prin tln("in For loop");
bos.write(("<tr ><td><b><a href=\"" +
f.getCanonicalP ath() + f.getName() +
"/\">" + f.getName() +
"/</a></b></td><td></td><td></td></tr>").getBytes( ));
}
else
{
System.out.prin tln("In else block");
bos.write(("<tr ><td><a href=\"" + f.getCanonicalP ath() +
f.getName() + "\">" + f.getName() +
"</a></td><td align=\"right\" >" + f.length() +
"</td><td>" + new Date(f.lastModi fied()).toStrin g() +
"</td></tr>").getBytes( ));
}
}
}
catch(IOExcepti on e)
{
e.printStackTra ce();
}
}
}
BufferedOutputS tream bos = new BufferedOutputS tream(s.getOutp utStream());
//PrintWriter out = new PrintWriter();
String line = br.readLine();
System.out.prin tln(line);
File f = new File(dirname,"i ndex.html");
System.out.prin tln( dirname + " is in run method" );
System.out.prin tln(f.getCanoni calPath());
File[] f2 = f.listFiles();
for(int j =0; j<f.length();j+ +)
{
System.out.prin tln("files are " + f2[j]);
}
/* in this write method i got error i.e in method wrinte(int) in the type BufferedOutputs tream is not applicable for the argument (string)*/
bos.write("HTTP/1.0 200 OK\r\n" +
"Content-Type: text/html\r\n" +
"<h1>Direct ory Listing</h1>" +
"<h3>" + f.getCanonicalP ath() +
"</h3>" + "<table border=\"0\" cellspacing=\"8 \">" +
"<tr><td><b>Fil ename</b><br></td><td align=\"right\" ><b>Size</b></td><td><b>Last Modified</b></td></tr>" +
"<tr><td><b ><a href=\"/\">/</b><br></td><td></td><td></td></tr>").getBytes( );
for(int i=0;i<f2.length ;i++)
{
f = f2[i];
if (f.isDirectory( ))
{
System.out.prin tln("in For loop");
bos.write(("<tr ><td><b><a href=\"" +
f.getCanonicalP ath() + f.getName() +
"/\">" + f.getName() +
"/</a></b></td><td></td><td></td></tr>").getBytes( ));
}
else
{
System.out.prin tln("In else block");
bos.write(("<tr ><td><a href=\"" + f.getCanonicalP ath() +
f.getName() + "\">" + f.getName() +
"</a></td><td align=\"right\" >" + f.length() +
"</td><td>" + new Date(f.lastModi fied()).toStrin g() +
"</td></tr>").getBytes( ));
}
}
}
catch(IOExcepti on e)
{
e.printStackTra ce();
}
}
}
Comment