-1

I would like to write my array of objects to an HTML file in a loop. The HTML tags are correct as the table that I want is properly made. However, "menu.ArrObj[i].getName" is literally printed. I would like some help as to how the actual array is to be printed.

FileWriter f = new FileWriter("C:\\drivers\\A.html", true);
BufferedWriter bw = new BufferedWriter(f);
for(int i = 0; i < 15; i++)
 {
     bw.write("</tr><tr><td>menu.ArrObj[i].getName()</td> <td> align=\"right\">menu.ArrObj[i].getConcept() </td> <td align=\"right\"
5
  • What programming language is that? Is it Java? Commented Mar 23, 2016 at 9:41
  • google.co.uk/… Commented Mar 23, 2016 at 9:42
  • It's Java language Commented Mar 23, 2016 at 9:43
  • 1
    Of course the literal value is printed, as it's a part of the write string and not used as a variable Commented Mar 23, 2016 at 9:43
  • 2
    Possible duplicate of Java - Including variables within strings? Commented Mar 23, 2016 at 9:44

1 Answer 1

3

It seems you just want to replace the BufferedWriter write line with:

 bw.write("</tr><tr><td>" + menu.ArrObj[i].getName() + "</td> <td> align=\"right\">" + menu.ArrObj[i].getConcept() + "</td> <td align=\"right\" ...)
Sign up to request clarification or add additional context in comments.

2 Comments

I'm changing it to that to see if it solves my issue
@RaghavKapur that sounds like an unrelated error. Do you know when NullPointerExceptions typically occur? Examine menu.ArrObj to see which of its elements are null

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.