If you are going to do this, you might as well generalize it to:
public class FileToString {
public synchronized static String convert(File input) throws
FileNotFoundException {
String output = "";
String line = "";
StringBuffer content = new StringBuffer();
BufferedReader reader = new BufferedReader(new FileReader(input));
try {
while((line = reader.readLine()) != null) {
content.append(line + "\n");
}
reader.close();
} catch (IOException ioe) {
ioe.printStackTrace();
content.append("ERROR: " + ioe.getMessage());
} finally {
}
return output = content.toString();
}
}
Or something similar?
Jack
On Thu, 25 Nov 2004 08:57:03 +0000, andy wix <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have resolved this now.
>
> The action code is:
>
> File f = new File("test.log");
>
> BufferedReader in = new BufferedReader(new FileReader(f));
> String str;
> while ((str = in.readLine()) != null) {
> buf.append("\n" + str);
> }
> in.close();
> request.setAttribute("FILE", buf.toString());
>
> and the jsp code (not pretty)is:
>
> <%
> String text = (String)request.getAttribute("FILE");
> StringTokenizer tok = new StringTokenizer(text,"\n");
>
> int count = tok.countTokens();
> while (tok.hasMoreTokens()){
> out.print(tok.nextToken());%>
> <BR>
> <%}
>
>
> Andy
>
> _________________________________________________________________
> It's fast, it's easy and it's free. Get MSN Messenger today!
>
>
> http://www.msn.co.uk/messenger
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
"You can't wake a person who is pretending to be asleep."
~Native Proverb~
"Each man is good in His sight. It is not necessary for eagles to be crows."
~Hunkesni (Sitting Bull), Hunkpapa Sioux~
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]