473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

i got error in the following code can any one help me..

BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
BufferedOutputStream bos = new BufferedOutputStream(s.getOutputStream());
//PrintWriter out = new PrintWriter();
String line = br.readLine();
System.out.println(line);
File f = new File(dirname,"index.html");
System.out.println( dirname + " is in run method" );
System.out.println(f.getCanonicalPath());
File[] f2 = f.listFiles();
for(int j =0; j<f.length();j++)
{
System.out.println("files are " + f2[j]);
}

/* in this write method i got error i.e in method wrinte(int) in the type BufferedOutputstream is not applicable for the argument (string)*/

bos.write("HTTP/1.0 200 OK\r\n" +
"Content-Type: text/html\r\n" +
"<h1>Directory Listing</h1>" +
"<h3>" + f.getCanonicalPath() +
"</h3>" + "<table border=\"0\" cellspacing=\"8\">" +
"<tr><td><b>Filename</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.println("in For loop");

bos.write(("<tr><td><b><a href=\"" +
f.getCanonicalPath() + f.getName() +
"/\">" + f.getName() +
"/</a></b></td><td></td><td></td></tr>").getBytes());

}
else
{
System.out.println("In else block");
bos.write(("<tr><td><a href=\"" + f.getCanonicalPath() +
f.getName() + "\">" + f.getName() +
"</a></td><td align=\"right\">" + f.length() +
"</td><td>" + new Date(f.lastModified()).toString() +
"</td></tr>").getBytes());

}

}

}

catch(IOException e)
{
e.printStackTrace();
}

}
}
Feb 17 '08 #1
1 1159
BigDaddyLH
1,216 Expert 1GB
Distinguish between binary I/O (InputStreams/OutputStreams) and character I/O (Readers/Writers). You are doing character output, so use a Writer like BufferedWriter or PrintWriter. Take the Sun tutorial on I/O: http://java.sun.com/docs/books/tutor.../io/index.html
Feb 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: xixi | last post by:
we are using db2 udb v8.1 on win 64 bit with fp3 with type 4 db2jcc.jar driver. such error generated , please help me understand this , thanks 2004-01-12-14.09.02.400000 Instance:DB2 ...
1
by: timVerizon | last post by:
Hoping someone can help here.. Our application (C#.Net) was receiving IBM.Data.DB2.DB2Exceptions ERROR SQL0904N Unsuccessful execution caused by an unavailable resource. Reason code: '', type...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
7
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with...
0
by: Ming Zhu | last post by:
Hi, all, I'm new to .NET and ASP.NET. I only use .NET Framework 1.0. I'm reading the book "C# developer's guide to ASP.NET". But I find there is no place to download the code used inside this...
6
by: Alixx Skevington | last post by:
OK why does the following code work in a Windows form with a crystal report viewer but not in a webform. I get the usual CrystalReports.EngineLogONException logon Failed when this is called in...
10
by: Shawn | last post by:
JIT Debugging failed with the following error: Access is denied. JIT Debugging was initiated by the following account 'PLISKEN\ASPNET' I get this messag in a dialog window when I try to open an...
2
by: mike_li | last post by:
On Window 2000 Professional Server DB2 UDB Level: DB2 code release "SQL07029" with level identifie "030A0105" and informational tokens "DB2 v7.1.0.98", "n040510" and "WR21337". In the...
2
by: tshad | last post by:
This has been driving me crazy. I have been trying to get the error handling working on my system and can get parts of it working and others won't work at all. I found that you can't access...
8
by: sara | last post by:
I have a report that runs fine with data. If there is no data, I have its NO Data event sending a MsgBox and cancelling the report. Then it seems I still get the 2501 message on the Open Report...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.