1

I am trying to print some values in new line but for some reason Java doesn't allow me to do it. Value for the second variable shows up in a new line but not for the third one. I've tried System.getProperty() and \n\n both gives me two new lines while I want just one line separator. Below is the code:

emailBody.append("Variable1: " + cu.getVariable1() + "\n");
emailBody.append("Variable2: " + cu.getVariable2() + "\n");
emailBody.append("Variable3: " + cu.getVariable3() + "\n");

On Console:

Variable1: 1

Variable2: 2 Variable3: 3

I am not sure why Variable3 does not go to the next line.

Thanks,

1 Answers1

5

I do it this way

private static final String LF = System.getProperty("line.separator");

emailBody.append("Variable1: " + cu.getVariable1() + LF);
emailBody.append("Variable2: " + cu.getVariable2() + LF);
emailBody.append("Variable3: " + cu.getVariable3() + LF);

If this does not work, then the problem is else where.

AlexWien
  • 28,470
  • 6
  • 53
  • 83